Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. import java.util.*;
  2. public class Temperature_Converter {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. boolean repeat = true;
  6. System.out.println("Welcome to my temperature converter");
  7. while (repeat) {
  8. System.out.println("Type 1 for Celcius to Fahrenheit and type 2 for Fahrenheit to Celcius");
  9.  
  10. int type = sc.nextInt();
  11.  
  12. if (type == 1) {
  13. System.out.println("please input the degress celcius");
  14. double cel = sc.nextDouble();
  15. double fah = (9.0/5 * cel) + 32;
  16. System.out.println(cel + " degress Celcius is equivilent to " + fah + " degress Fahrenheight");
  17. }
  18. else if (type == 2) {
  19. System.out.println("please input the degress Fahrenheight");
  20. double fah = sc.nextDouble();
  21. double cel = (fah - 32) * 5/9.0;
  22. System.out.println(fah + " degress Fahrenheight is equivilent to " + cel + " degress Celcius");
  23. }
  24. System.out.println("Would you like to go again? (Yes or No)");
  25. sc.nextLine();
  26. String response = sc.nextLine();
  27. if (response.equals("yes")) {
  28.  
  29. }
  30. else {
  31. repeat = false;
  32. }
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement