Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner scanner = new Scanner(System.in);
- double temperature;
- byte mode = 0;
- boolean keepLooping;
- System.out.println("CONVERTISSEUR DEGRES CELSIUS ET DEGRES FARHENHEIT" + "\n" +
- "--------------------------------------------------------");
- while (mode != 1 && mode != 2) {
- System.out.println("Choisissez le mode de conversion" + "\n" +
- "1 - Convertisseur Celsius - Farhenheit" + "\n" +
- "2 - Convertisseur Farhenheit - Celsius");
- mode = scanner.nextByte();
- }
- do {
- System.out.println("Température à convertir : ");
- temperature = scanner.nextDouble();
- if (mode == 1) {
- System.out.println(temperature + "°C correspond à : " + 9 / 5 * temperature + 32 + "°F.");
- } else {
- System.out.println(temperature + "°F correspond à : " + (temperature - 32) * 5 / 9 + "°C.");
- }
- char c = ' ';
- while (c != 'o' && c != 'n') {
- System.out.println("Souhaitez-vous convertir une autre température (O/N)");
- String s = scanner.next();
- c = s.toLowerCase().charAt(0);
- }
- keepLooping = c == 'o';
- } while (keepLooping);
- System.out.println("Au revoir mec !");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement