/* The gradekeep class implements the grade keeping application */ import java.util.Scanner; import java.io.*; public class gradekeep { /* declare the student objects */ final int NUMSTUDENTS = 4; student s1, s2, s3, s4; /* declare easyin */ Scanner easy; /* main method */ public static void main(String[] args) throws IOException { gradekeep gk = new gradekeep(); gk.populate(); gk.printRecords(); } /* this method asks the user to input student data */ public void populate() throws IOException { easy = new Scanner (new File("C:\\Documents and Settings\\tessier\\My Documents\\class\\ece122\\lectures\\lect06\\input.txt")); System.out.println("Enter 4 student records."); s1 = new student(); ask(s1); s2 = new student(); ask(s2); s3 = new student(); ask(s3); s4 = new student(); ask(s4); } /* this prompts the user for input */ public void ask(student studentobj) { System.out.print("name> "); studentobj.setName(easy.nextLine()); System.out.print("\ngrade> "); studentobj.setGrade(easy.nextLine()); System.out.println(""); } /* this method displays the student data that has been collected */ public void printRecords() { System.out.println(s1.getName() + " has a grade of " + s1.getGrade()); System.out.println(s2.getName() + " has a grade of " + s2.getGrade()); System.out.println(s3.getName() + " has a grade of " + s3.getGrade()); System.out.println(s4.getName()+ " has a grade of " +s4.getGrade()); // double avg = (s1.getGPA() + s2.getGPA() + s3.getGPA() + s4.getGPA()) / NUMSTUDENTS; // System.out.println("Average GPA for the course is: "+ avg); } }