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-19 20:56

(defn c-to-f [temp]
  (+ 32 (* 1.8 temp)))

(defn f-to-c [temp]
  (/ (- temp 32) 1.8))

(defn main []
  (println "Input temperature in C or F: ")
  (let [temp
    (Double/parseDouble (read-line))]
    (printf "%.2f F\n" (c-to-f temp))
    (printf "%.2f C\n" (f-to-c temp))))

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