Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java

Name: Anonymous 2009-02-18 0:06

I need to convert a user inputted temperature from Celsius to Fahrenheit. this is what I have so far:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
 
    public static void main(String[] args) {
       privateMain(args);
    }

    private static void privateMain(String[] privateArgs) {
        System.out.println("Enter C or F <return>");
        BufferedReader in =
            new BufferedReader(new InputStreamReader(System.in));
        String type = null;
        try {
            type = in.readLine();
        } catch (IOException e) {
           
            e.printStackTrace();
        }
        if (type=);
        {
          //statements 
        }
        else
            //statements
        System.out.println("Converted is: " + temp);

       
    }
}

How do I take the input, read it as  Celsius or Fahrenheit, and convert it with the if statement? And i know I suck at programming, so you don't have to tell me

Name: Anonymous 2009-02-18 22:08

>>21
Incorrect.

15.18.1.2 Optimization of String Concatenation
An implementation may choose to perform conversion and concatenation in one step to avoid creating and then discarding an intermediate String object. To increase the performance of repeated string concatenation, a Java compiler may use the StringBuffer class or a similar technique to reduce the number of intermediate String objects that are created by evaluation of an expression.

For primitive types, an implementation may also optimize away the creation of a wrapper object by converting directly from a primitive type to a string.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List