10% discount to children who are not more than 12 years old or senior citizens who are at least 65 years old. It is further stated that ONLY those who are visiting the Park for at least the 5th time will qualify for this discount
public class KrugerNationalPark {
public static void main(String[] args){
String Age, Visit;
Age = 18;
Visit = 10;
decideDiscount(Age, Visit);
}
public static void decideDiscount(double A, char V)
{
if ((A <= 12 && >= 65) && (V >= 5));
System.out.print("You qualify for 10% discount!")
System.out.print("You deserve it!")
else
System.out.print("You do not qualify for discount")
}
}
the program is not executing due to at least 10 syntax errors.
1) You are required to debug the program and re-write the program without errors.
2) Re-write your program in such a way that method decideDiscount() can return a value to the calling method. The calling method will then display if a customer qualifies for a discount or not.
public class KrugerNationalPark {
public static void main(String[] args) {
double Age;
int Visit;
Age = 18;
Visit = 10;
System.out.print(decideDiscount(Age, Visit));
}
public static String decideDiscount(double A, int V) {
if ((A <= 12 || A >= 65) && (V >= 5)) {
return "You qualify for 10% discount!" + "\nYou deserve it!";
}
return "You do not qualify for discount";
}
}
Comments
Leave a comment