Basically my code supposes to calculator the weight by using the height. The user has to choose between if he/she is male or female. After that, the if-else statement supposes to do the calculation. The problem is when the user types the choice between Male or Female. The code neglects the choice and goes to the else statement right away to tell that your choice is wrong.
import java.util.Scanner;
public class cals {
public static void main(String[] args) {
Scanner Scan = new Scanner(System.in);
System.out.println("\nAre you Male or Female: ");
String Choice = Scan.nextLine();
if (Choice == "Male") {
System.out.println("What is your hight in CMeters: ");
int Height = Scan.nextInt();
if (Height > 160) {
int Your_weight = (Height - 100) * 90 / 100;
System.out.println("Your_weight is: " + Your_weight);
}
else {
int Your_weight = (Height - 100);
System.out.println("Your_weight is: " + Your_weight);
}
}
else if (Choice == "Female") {
System.out.println("What is your hight in CMeters: ");
int Height = Scan.nextInt();
if (Height > 160) {
int Your_weight = (Height - 100) * 90 / 100;
System.out.println("Your_weight is: " + Your_weight);
}
else {
int Your_weight = (Height - 100);
System.out.println("Your_weight is: " + Your_weight);
}
}
else {
System.out.println("you Enter a worng choice");
}
}
}