Début (programme conversion température) - problème
Bonjour à tous !
Pouvez-vous m'aider s'il vous plaît :)
Dites-moi pourquoi ce code est mauvais, ça ne fonctionne pas je comprends absolument pas (je débute tout juste)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| import java.util.Scanner;
public class ConvertisseurTemperature {
public static void main(String[] args) {
char reponse = ' ', mode = ' ';
Scanner scan = new Scanner(System.in);
while (reponse == 'O')
{
mode = ' ';
System.out.println("CONVERTISSEUR DEGRES CELSIUS ET DEGRES FAHRENHEIT");
System.out.println("-------------------------------------------------");
System.out.println("Choisissez le mode de conversion :");
System.out.println("1 - Convertisseur Celsius - Fahrenheit");
System.out.println("2 - Convertisseur Fahrenheit - Celsius");
mode = scan.nextLine().charAt(0);
System.out.println("Température à convertir :");
double d = scan.nextDouble();
scan.nextLine();
double c;
double f;
f = ((9/5)*d+32);
c = ((d-32)*5)/9;
if (mode == '1')
System.out.println(d + " correspond à : " + f + "°F");
else if (mode=='2')
System.out.println(d + " correspond à : " + c + "°C");
reponse = ' ';
} while(reponse != 'O' && reponse != 'N')
{
System.out.println("Souhaitez-vous convertir une autre température ? (O/N)");
reponse = scan.nextLine().charAt(0);
}
}
} |