A restaurant is deciding to give a discount to customers based on their age. Children under 12 years old will get a discount of 20%, while all other people will get no discount. Write a program that takes an age as an input and outputs what kind of discount a person of that age would get. Comment your solution below.
top of page
bottom of page
import java.util.Scanner;
class Main {
publicstaticvoid main(String[] args) {
System.out.println("What is your age?");
Scanner sc = new Scanner(System.in);
double b = sc.nextln();
if (b < 0 ) {
System.out.println("Invalid Age");
} elseif (0 < b < 13) {
System.out.println("Fortunately, you have a 20% discount!");
} else {
System.out.println("You will need to pay the full price of what you are ordering.");
}
}
}