// Lab 11 Exercise 4 // Programmer: Daniel Hunt // Editor(s) used: Win 7 JNotePad // Compiler(s) used: Java SE 6 // Description: This program builds a class with different types of data variables. It // prompts the user to import java.io.*; class Student { String name; String address; String city; String state; int zip; char gender; int id; float gpa; void printResults() { System.out.println("Student's name: " + name); System.out.println("Student's address: " + address); System.out.println("Student's city: " + city); System.out.println("Student's state: " + state); System.out.println("Student's zip: " + zip); System.out.println("Student's gender: " + gender); System.out.println("Student's id: " + id); System.out.println("Student's gpa: " + gpa); } void askForInput() { BufferedReader cin; cin = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Student 1's name: "); name = cin.readLine(); System.out.print("Student 1's address: "); address = cin.readLine(); System.out.print("Student 1's city: "); city = cin.readLine(); System.out.print("Student 1's state: "); state = cin.readLine(); System.out.print("Student 1's zip: "); zip = new Double(cin.readLine()).intValue(); System.out.print("Student 1's gender [M/F]: "); gender = cin.readLine().charAt(0); System.out.print("Student 1's id: "); id = new Double(cin.readLine()).intValue(); System.out.print("Student 1's gpa: "); gpa = new Double(cin.readLine()).floatValue(); } } public class StudentTest { public static void main(String[] argv) throws Exception { // declare and initialize array for Student class Student[] students = new Student[3]; for(int i = 0; i < students.length; i++) student[i] = new Student(); for(Student student : students) { student.askForInput(); student.printResults(); } } }