Advertisement
iSach

Untitled

Aug 2nd, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. Scanner scanner = new Scanner(System.in);
  2. double temperature;
  3. byte mode = 0;
  4. boolean keepLooping;
  5. System.out.println("CONVERTISSEUR DEGRES CELSIUS ET DEGRES FARHENHEIT" + "\n" +
  6. "--------------------------------------------------------");
  7. while (mode != 1 && mode != 2) {
  8. System.out.println("Choisissez le mode de conversion" + "\n" +
  9. "1 - Convertisseur Celsius - Farhenheit" + "\n" +
  10. "2 - Convertisseur Farhenheit - Celsius");
  11. mode = scanner.nextByte();
  12. }
  13. do {
  14. System.out.println("Température à convertir : ");
  15. temperature = scanner.nextDouble();
  16.  
  17. if (mode == 1) {
  18. System.out.println(temperature + "°C correspond à : " + 9 / 5 * temperature + 32 + "°F.");
  19. } else {
  20. System.out.println(temperature + "°F correspond à : " + (temperature - 32) * 5 / 9 + "°C.");
  21. }
  22.  
  23. char c = ' ';
  24. while (c != 'o' && c != 'n') {
  25. System.out.println("Souhaitez-vous convertir une autre température (O/N)");
  26. String s = scanner.next();
  27. c = s.toLowerCase().charAt(0);
  28. }
  29. keepLooping = c == 'o';
  30.  
  31. } while (keepLooping);
  32.  
  33. System.out.println("Au revoir mec !");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement