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.");
}
}
}
Asked
Active
Viewed 57 times
0
-
Essentially, *Terminated Application* indicates that the execution of the program is complete and the Java Virtual Machine has exited. It will appear even if your program exits with no error so it doesn't necessarily mean that something has gone wrong. PS: It seems that you need to have a look at [this question](https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) in order to have a better understanding on how you should compare Strings in Java. – Giorgos Myrianthous Feb 20 '19 at 17:17
1 Answers
2
Here (args[0] == "Female") is wrong , in java == checks the memory location of the String (objects) where these will be saved. You should use (args[0].equals("Female")) or (args[0].equalsIgnoreCase("Female"))

Navneet Kumar
- 273
- 1
- 11