Answer to Question #8973 in Java | JSP | JSF for java program
2012-05-08T10:29:15-04:00
create a simple java program that enter his name, surname and age. Note that the program has an age limit of 18 years old.
1
2012-05-08T11:43:33-0400
import java.util.Scanner; public class Main { private static Scanner input=new Scanner(System.in); private static String[] aray=new String[3]; public static void main(String[] args) { System.out.print("Enter your name: "); aray[0]=input.nextLine(); System.out.print("Enter your surname: "); aray[1]=input.nextLine(); System.out.print("Enter your age: "); EnterAge(); System.out.println("Your name is: "+aray[0]); System.out.println("Your surname is: "+aray[1]); System.out.println("Your age is: "+aray[2]); } private static void EnterAge(){ String age =input.nextLine(); if(Integer.parseInt(age)<1 && Integer.parseInt(age)>18){ EnterAge(); }else{ aray[2]=age; } } }
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 !
Learn more about our help with Assignments:
Java JSP JSF
Comments
Leave a comment