Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. package tw.seifert.myproject.homework;
  2.  
  3. import java.util.*;
  4.  
  5. public class CtoFHomework01 {
  6.  
  7. public static void main(String[] args) {
  8. System.out.println("Please inpute 1 or 0");
  9.  
  10. Scanner sc = new Scanner(System.in);
  11. int index = sc.nextInt();
  12. if(index == 1) {
  13. System.out.println("Please input the Fahrenheit degree.");
  14. Scanner scF = new Scanner(System.in);
  15. double Fahrenheit = sc.nextInt();
  16. double Celsius = (Fahrenheit-32)*(5/9);
  17. System.out.println(Fahrenheit + " Fahrenheit = " + Celsius + " Celsius.");
  18. }else if(index == 0){
  19. System.out.println("Please input the Celsius degree.");
  20. Scanner scC = new Scanner(System.in);
  21. double Celsius = sc.nextInt();
  22. double Fahrenheit = (Celsius*9/5+32);
  23. System.out.println(Celsius + " Celsius = " + Fahrenheit + " Fahrenheit.");
  24. }else{
  25. System.out.println("You should input 1 or 0.");
  26. }
  27.  
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement