Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Brandon Murphy
- import java.util.Scanner;
- public class TemperatureConversion
- {
- public static void main(String [] args)
- {
- int tempF[];
- int tempC[];
- int tempNew[];
- double freezingPoint[] = new double[32];
- System.out.print( "Enter F to convert Fahrenheit, C to convert Celsius. " );
- Scanner scanner = new Scanner(System.in);
- String conversionType = scanner.nextLine();
- System.out.print( "Please enter the temperature you would like to convert. " );
- String tempValue = scanner.nextLine();
- double tempDouble = Double.parseDouble(tempValue);
- if (conversionType == "F"){
- tempC = (5.0 / 9 * tempDouble - freezingPoint);
- System.out.println( tempValue + "in Celsius is" + tempC);
- }
- if (conversionType == "C"){
- tempC = (tempDouble * 9.0 / 5 + freezingPoint);
- System.out.println( tempValue + "in Fahrenheit is" + tempF);
- }
- else {
- System.out.println( "Invalid temperature type" );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement