我对编码很陌生,似乎无法弄清楚如何让它打印我知道的烘焙名称,因为它试图识别一个单数字符,但我不知道如何让它识别多个。
public static void main(String[] args) {
int ingredients = 5+4+9+8+201+200+202+2+1+203;
char bake;
if (ingredients >= 835) {
bake = 'Cookies';
} else if (ingredients >= 80) {
bake = 'C';
} else if (ingredients >= 70) {
bake = 'B';
} else if (ingredients >= 60) {
bake = 'D';
} else {
bake = 'W';
}
System.out.println("You can make " + bake);
}