Bonjour,
J'ai écrit un bout de code qui me ramène à l'exécution une erreur :Qui est je pense liée aux variables.Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Type mismatch: cannot convert from char to boolean
Type mismatch: cannot convert from char to boolean
at ConvertisseurTempératures.convertirTempérature(ConvertisseurTempératures.java:14)
at ConvertisseurTempératures.main(ConvertisseurTempératures.java:32)
Voici le code en question :Quelqu'un saurait-il m'indiquer d'où peut venir le problème ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public class ConvertisseurTempératures { public long convertirTempérature(int température, char Ttype){ String notification; long TenF ; long TenC ; Ttype = 'C'; if (Ttype='F') { TenF = 10 * température + 32; notification = "Essai1 "+ TenF ; System.out.println(notification); } else if (Ttype='C'){ TenC = 15 * température - 10; notification = "Essai2 "+ TenC; System.out.println(notification); } return Ttype; return TenF; return TenC; public static void main(String[] args) { ConvertisseurTempératures convertisseur = new ConvertisseurTempératures(); convertisseur.convertirTempérature(5, 'C'); } }
Merci d'avance pour votre aide.
Partager