Guest User

Untitled

a guest
Dec 11th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TempConverter3{
  4. public static void main(String[] args) {
  5. double f;
  6. double c;
  7. int 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. System.out.println("Type 1 for Farenheit and 2 for Celcius.");
  13. type = kb.nextInt();
  14.  
  15. if(type== 1){
  16. System.out.println("What temperature is it?");
  17. f = kb.nextDouble();
  18. c = (f-32)/1.8;
  19. System.out.println("The temperature is " + c + " degrees Celcius.");
  20. }
  21.  
  22. else if(type==2) {
  23. System.out.println("What temperature is it?");
  24. c = kb.nextDouble();
  25. f = (c*1.8) + 32;
  26. System.out.println("The temperature is " + f + " degrees Farenheit.");
  27. }
  28.  
  29. else{
  30. System.out.println("Did you spell something wrong? Try Celcius or Farenheit");
  31. }
  32. }
  33. }
Add Comment
Please, Sign In to add comment