Answer to Question #252684 in Java | JSP | JSF for Olwam

Question #252684

The average age to obtain a driver’s licence is 18. Write a Java program where the user enters his / her age. If the age is greater than or equal to 18, the program must display using JOptionPane the following message, “you are old enough to apply for a driver’s licence”, else display the following message, “you are not old enough to apply for a driver’s licence”. 


1
Expert's answer
2021-10-18T00:14:36-0400
import java.util.Scanner;
import javax.swing.*;  
public class Main
{
	public static void main(String[] args) {
	    JFrame f=new JFrame();
		int age;
		Scanner in=new Scanner(System.in);
		System.out.println("Enter your age: ");
		age=in.nextInt();
		
		if (age>=18){
		    JOptionPane.showMessageDialog(f,"you are old enough to apply for a driver’s licence");  
		}
		else{
		    JOptionPane.showMessageDialog(f,"you are not old enough to apply for a driver’s licence");  
		}
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Olwam
18.10.21, 08:06

Wow thank you so very much! That was very quick

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS