In: Computer Science
Write a Java program that will display different messages depending on your age.
Your program should ask the user for his/her name and their age in years
and give one or more answers from the following ones below:
import java.util.Scanner;
public class Messages {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter your age: ");
int age = in.nextInt();
if (age < 16) {
System.out.println("You are not allowed to drive at the moment");
}
if (age < 18) {
System.out.println("You are not allowed to vote at the moment");
}
if (age < 25) {
System.out.println("You are not allowed to rent a car at the moment");
}
if (age >= 25) {
System.out.println("You can do anything that is legal");
}
}
}

