Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. public static void main(String[] args)
  2. {
  3. Scanner sc = new Scanner (System.in);
  4. String choix = "";
  5. String reponse = "";
  6.  
  7. do {
  8. System.out.println("Quel est la température à calculer ?");
  9. int temperature = sc.nextInt();
  10. System.out.print("Désirez vous 1.convertir de °C à far ou 2.de far en °C");
  11. sc.nextLine();
  12. reponse.equals(sc.nextLine());
  13. do{
  14. if (reponse.equals("1")){
  15. temperature = 9/5*temperature+33;
  16. System.out.print("Cela correspond à " +temperature +"°F");
  17. }else if(reponse == "2"){
  18. temperature = ((temperature-32)*5)/9;
  19. System.out.print("Cela correspond à " +temperature +"°C");
  20. }else{
  21. System.out.print("Tu dois répondre 1 ou 2, pas autre chose, recommence");
  22. }
  23. }while(!reponse.equals("1")||!reponse.equals("2"));
  24. System.out.println("Voulez vous recommencer ?(0/N)");
  25. choix = sc.nextLine();
  26. }while(!choix.equals("N"));
  27. sc.close();
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement