Tuesday, 10 October 2017

java function program take personal information


import java.util.*;
class person
{
  Scanner p = new Scanner(System.in);
  String name,address,gender;
 int age,id;
  String name()
{
   System.out.println("Enter the name of person ");
  name=p.nextLine();
  return name;
}
 int age()
{
   System.out.println("Enter the age of person ");
  age=p.nextInt();
 return age;
}
 String gender()
{
   System.out.println("Enter the gerder of person ");
  gender=p.nextLine();
 return gender;
}
int id()
{
   System.out.println("Enter the id of person ");
  id=p.nextInt();
 return id;
}
 String address()
{
   System.out.println("Enter the address of person ");
  address=p.nextLine();
 return address;
}}
public class personInformation
{
  public static void main(String args[])
{
 Scanner p = new Scanner(System.in);
 System.out.println("Enter the number of repitition :");
  int n=p.nextInt();
 person bilal = new person();
for (int i=1;i<=n;i++)
{
 
 System.out.println("Your name is  :"+bilal.name());
  System.out.println("Your age is  :"+bilal.age());
System.out.println("Your gender is  :"+bilal.gender());
System.out.println("Your id is  :"+bilal.id());
System.out.println("Your address is  :"+bilal.address());
}}} 

0 comments:

Post a Comment