In: Computer Science
This for Java Programming
Write a java statement to read the Age input value
4 . Redo 1 to 3 using JOptionPane
Here is the Java code for the given question.
Code for 1,2,3:
import java.util.*;    /* (1) Imports Java utilities */
public class ReadAge {
    public static void main(String[] args){
        Scanner scanner=new Scanner(System.in);    /* (2) Creates a Scanner object to read input */
        int Age;
        Age=scanner.nextInt();     /* (3) Statement to read Age input value */
    }
}
Output:
According to the question, the program produces no output ,but input is taken as follows:

Code for 4:
import javax.swing.*;   /* (1) imports java swing*/
public class ReadAgeJOptionPane {
    public static void main(String[] args){
        int Age;   /*used to store Age*/
        JOptionPane optionPane=new JOptionPane();    /* (2)creates a new JOptionPane object*/
        Age= Integer.parseInt(optionPane.showInputDialog("Enter Age:"));      /* (3)statement to read Age input value*/
    }
}
Output:
According to the question, the program produces no output ,but input is taken as follows:
