Hi all...
I am compiling this simple program which determines the ticket price for the person, depending on the criteria entered.
My problem is, however, that the answer at the end is always "FREE" (as if the program is not considering the other if branches =(
Any idea of what might be wrong with this program pls?
I am compiling this simple program which determines the ticket price for the person, depending on the criteria entered.
My problem is, however, that the answer at the end is always "FREE" (as if the program is not considering the other if branches =(
Code:
System.out.println("Enter your age ");
int age = Keyboard.readInt();
System.out.println("Enter your locality (Maltese/Gozitan) ");
String loc = Keyboard.readString();
String price ;
if ((age < 15 ) && (loc == "Gozitan")) price = "EUR 0.3" ;
else if ((age < 15 ) && (loc == "Maltese")) price = "EUR O.5" ;
else if ((( age > 14) && (age < 60 )) && loc == "Gozitan" ) price = "EUR 1";
else if ((( age > 14) && (age < 60 )) && loc == "Maltese" ) price = "EUR 2";
else price = "FREE" ;
System.out.println ("Your ferry ticket costs " +price);
Comment