package javagain;
public class Gender_interest {
public static void main(String args[]) {
if((args[0] == "Female") && (Integer.parseInt(args[1])>=1) && (Integer.parseInt(args[1])<=58)) {
System.out.println("Percentge of Interest is 8.2%");
}
else if((args[0] == "Male") && (Integer.parseInt(args[1])>=1) && (Integer.parseInt(args[1])<=58)) {
System.out.println("Percentge of Interest is 8.4%");
}
else if((args[0] == "Female") && (Integer.parseInt(args[1])>=59) && (Integer.parseInt(args[1])<=100)) {
System.out.println("Percentge of Interest is 9.2%");
}
else if((args[0] == "Male") && (Integer.parseInt(args[1])>=59) && (Integer.parseInt(args[1])<=100)) {
System.out.println("Percentge of Interest is 10.5%");
}
else {
System.out.println("Enter correct values.");
}
}
}
答案 0 :(得分:2)
这里(args [0] ==“ Female”)是错误的,在java ==中检查了将要保存这些字符串(对象)的内存位置。您应该使用(args [0] .equals(“ Female”))或(args [0] .equalsIgnoreCase(“ Female”))