Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. // Brandon Murphy
  2.  
  3. import java.util.Scanner;
  4. public class TemperatureConversion
  5. {
  6. public static void main(String [] args)
  7. {
  8. int tempF[];
  9. int tempC[];
  10.  
  11. int tempNew[];
  12.  
  13. double freezingPoint[] = new double[32];
  14.  
  15. System.out.print( "Enter F to convert Fahrenheit, C to convert Celsius. " );
  16. Scanner scanner = new Scanner(System.in);
  17. String conversionType = scanner.nextLine();
  18.  
  19. System.out.print( "Please enter the temperature you would like to convert. " );
  20. String tempValue = scanner.nextLine();
  21. double tempDouble = Double.parseDouble(tempValue);
  22.  
  23. if (conversionType == "F"){
  24. tempC = (5.0 / 9 * tempDouble - freezingPoint);
  25. System.out.println( tempValue + "in Celsius is" + tempC);
  26. }
  27.  
  28. if (conversionType == "C"){
  29. tempC = (tempDouble * 9.0 / 5 + freezingPoint);
  30. System.out.println( tempValue + "in Fahrenheit is" + tempF);
  31. }
  32.  
  33. else {
  34. System.out.println( "Invalid temperature type" );
  35. }
  36.  
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement