-1
public static void main(String[] args) {
System.out.println("Bitte geben Sie einen Betrag und den Buchstaben der gewunschten Wahrung ein.");
try {
Scanner input = new Scanner(System.in);
double betrag = input.nextInt();
String wahrung = input.next();
double result = 0;
switch(wahrung.charAt(0)) {
case d:
result = betrag * 1.18;
System.out.println(result);
break;
case p:
result = betrag * 0.88;
System.out.println(result);
break;
case f:
result = betrag * 0.88;
System.out.println(result);
break;
}
} catch (Exception e) {
System.out.println("Bitte geben Sie eine Zahl ein.");
}
}
當我嘗試編譯它,它說:爪哇 - 錯誤:無法找到符號 - 開關/箱
Rechner.java:18:錯誤:無法找到符號 情況d: ^ 符號:可變d 位置:類雷希納 Rechner.java:22:錯誤:找不到符號 情況p: ^ 符號:變量p 位置:類雷希納 Rechner.java:26:錯誤:找不到符號 情況下f: ^ 符號:變量f 位置:類雷希納
請幫助
它的字符''p''不僅沒有'p' –
真棒,我討厭這些小東西.. – xVaskii
堅持下去,你也會得到它的竅門:) –