英文:
double value cannot be converted to boolean
问题
I'm just not sure why I'm getting this error, I would appreciate it if you could help me out to find the error. here is the code,
import java.util.Scanner;
public class FirstSelectionProgram {
public static void main(String[] args) {
Scanner key = new Scanner(System.in);
double spent;
System.out.println("Please Enter The Amount That You Have Spent: ");
spent = key.nextDouble();
if (0.01 <= spent && spent <= 40) {
System.out.println("you will receive 20% off");
} else {
System.out.println("you won't receive anything");
}
}
}
我只翻译代码部分。
英文:
I'm just not sure why I'm getting this error, I would appreciate it if you could help me out to find the error. here is the code,
import java.util.Scanner;
public class FirstSelectionProgram {
public static void main(String[] args) {
Scanner key=new Scanner(System.in);
double spent;
System.out.println("Please Enter The Amount That You Have Spent: ");
spent= key.nextDouble();
if (0.01=<spent && spent=<40)
{
System.out.println("you will receive 20% off");
}
else
{
System.out.println("you won't receive anything");
}
}
}
答案1
得分: 1
"Instead of doing if (0.01 <= spent && spent <= 40)
try if (0.01 <= spent && spent <= 40)
"
英文:
Instead of doing if (0.01=<spent && spent=<40)
try if (0.01 <= spent && spent <= 40)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论