Guest User

Untitled

a guest
Dec 11th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TempConverter2{
  4. public static void main(String[] args) {
  5. Double f;
  6. Double c;
  7. String type;
  8.  
  9. Scanner kb = new Scanner(System.in);
  10. System.out.println("This program converts temperature.");
  11. System.out.println("Do you want to convert from Farenheit or Celcius?");
  12. type = kb.nextLine();
  13.  
  14. if(type=="Farenheit"){
  15. System.out.println("What temperature is it?");
  16. f = kb.nextDouble();
  17. c = (f-32)/1.8;
  18. System.out.println("The temperature is " + c + " degrees Celcius.");
  19. }
  20.  
  21. if(type=="Celcius") {
  22. System.out.println("What temperature is it?");
  23. c = kb.nextDouble();
  24. f = (c*1.8) + 32;
  25. System.out.println("The temperature is " + f + " degrees Farenheit.");
  26. }
  27.  
  28. else{
  29. System.out.println("Did you spell something wrong? Try Celcius or Farenheit");
  30. }
  31. }
  32. }
Add Comment
Please, Sign In to add comment