Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package messingaround;
- import java.util.ArrayList;
- import java.util.Scanner;
- public class GradeKeeper {
- public static void main(String[] args) {
- ArrayList<StudentGrades> students = new ArrayList<StudentGrades>();
- // Create the list of students
- Scanner in = new Scanner(System.in);
- boolean done = false;
- while (!done)
- {
- System.out.print("Enter student name, or DONE if finished: ");
- String input= in.nextLine();
- if (!input.equalsIgnoreCase("done"))
- {
- students.add(new StudentGrades(input));
- }
- else
- {
- done=true;
- }
- }
- // Create the list of assignment names
- ArrayList<String> assignmentNames = new ArrayList<String>();
- done = false;
- while (!done)
- {
- System.out.print("Enter assignment name, or DONE if finished: ");
- String input = in.nextLine();
- if (!input.equalsIgnoreCase("done"))
- {
- assignmentNames.add(input);
- }
- else
- {
- done = true;
- }
- }
- //Takes students and their assignments and adds a score
- for(int studentIndex=0; studentIndex<students.size(); studentIndex++ )
- {
- for(int assignmentIndex=0; assignmentIndex<assignmentNames.size(); assignmentIndex++)
- {
- System.out.println("Enter score for "+ students.get(studentIndex).recordGrade(assignmentNames.get(assignmentIndex)));
- double score = in.nextDouble();
- }
- }
- for (int i = 0; i < students.size(); i++) {
- System.out.println(students.get(i).toString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement