rendered paste bodypublic class Students
{
static void printResults(int record)
{
// echo the results
System.out.println("Student's name: " + a[record)].name);
System.out.println("Student's address: " + a[record)].address);
System.out.println("Student's city: " + a[record)].city);
System.out.println("Student's state: " + a[record)].state);
System.out.println("Student's zip: " + a[record)].zip);
System.out.println("Student's gender: " + a[record)].gender);
System.out.println("Student's id: " + a[record)].id);
System.out.println("Student's gpa: " + a[record)].gpa);
}
static void askForInput(int record)
{
BufferedReader cin;
cin = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Student 1's name: ");
a[record)].name = cin.readLine();
System.out.print("Student 1's address: ");
a[record)].address = cin.readLine();
System.out.print("Student 1's city: ");
a[record)].city = cin.readLine();
System.out.print("Student 1's state: ");
a[record)].state = cin.readLine();
System.out.print("Student 1's zip: ");
a[record)].zip = new Double(cin.readLine()).intValue();
System.out.print("Student 1's gender [M/F]: ");
a[record)].gender = cin.readLine().charAt(0);
System.out.print("Student 1's id: ");
a[record)].id = new Double(cin.readLine()).intValue();
System.out.print("Student 1's gpa: ");
a[record)].gpa = new Double(cin.readLine()).floatValue();
} // askForInput
public static void main(String[] argv) throws Exception
{
// declare and initialize array for Student class
Student[] a = new Student[2];
for(int i = 0; i < a.length; i++)
a[i] = new Student();
for(int i = 1; i < 4; i++)
{
askForInput(i);
printResults(i);
}
}
}