JAVA Program to Accept Details of Voters in Array and Display it

JAVA Program to Accept Details of Voters in Array and Display it:

class voter
{
 String voter_name,voter_address;
 int votercontactno,voteradhar;

 voter(String vn, String va,int vcn,int vad)
 {
  voter_name=vn;
  voter_address=va;
  votercontactno=vcn;
  voteradhar=vad;
 }

 void display()
 {
   System.out.println("Voter Name: "+voter_name);
   System.out.println("Voter Address: "+voter_address);
   System.out.println("Voter Contact Number: "+votercontactno);
   System.out.println("Voter Adhar: "+voteradhar);
 }

 public static void main(String args[])
 {
  voter v[]=new voter[5];
  v[0]=new voter("Rahul","Nashik",21458,14785238);
  v[1]=new voter("Nitesh","Pune",25742,36985254);
  v[2]=new voter("Ranjish","Nagpur",58741,12543658);
  v[3]=new voter("Pranav","Mumbai",45875,24596587);
  v[4]=new voter("Nikhil","Gangapur",45896,27412563);

  for(int i=0;i<5;i++)
  {
   v[i].display();
  }
 }
}

OUTPUT:

Voter Name: Rahul
Voter Address: Nashik
Voter Contact Number: 21458
Voter Adhar: 14785238

Voter Name: Nitesh
Voter Address: Pune
Voter Contact Number: 25742
Voter Adhar: 36985254

Voter Name: Ranjish
Voter Address: Nagpur
Voter Contact Number: 58741
Voter Adhar: 12543658

Voter Name: Pranav
Voter Address: Mumbai
Voter Contact Number: 45875
Voter Adhar: 24596587

Voter Name: Nikhil
Voter Address: Gangapur
Voter Contact Number: 45896
Voter Adhar: 27412563

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.