-
-
Save NickCarneiro/1792162 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
public class Temperature{ | |
public static void main(String[] args){ | |
//the data that will be entered by the user | |
String farenheit1; | |
//an instance of the BufferedReader class | |
//will be used to read the data | |
BufferedReader reader; | |
//specify the reader variable | |
//to be a standard input buffer | |
reader = new BufferedReader(new InputStreamReader(System.in)); | |
System.out.println("What is the farenheit?"); | |
try{ | |
//read the data entered by the user using | |
//the readLine() method of the BufferedReader class | |
//and store the value in the name variable | |
float farenheit = Float.parseFloat(reader.readLine()); | |
float celsius = (farenheit-32)*5/9; | |
//print the data entered by the user | |
System.out.println("The fahrenheit is " + farenheit); | |
System.out.println("The celcius is " + celsius); | |
} | |
catch (IOException ioe){ | |
//statement to execute if an input/output exception occurs | |
System.out.println("An unexpected error occured."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment