60 384
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #8973 in Java | JSP | JSF for java program

Question #8973
create a simple java program that enter his name, surname and age. Note that the program has an age limit of 18 years old.
Expert's answer
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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions