For this lab, you will complete a program that allows a teacher to enter the first name and a test score for the students in his or her class. Assume that the teacher has already entered the names and test scores of some of the students in the class and have stored this information in a text file called student_scores.txt. The contents of that file resembles the following example below.
(Example text file)
James 88
Ronda 92
Benjamin 85
Sarah 97
Frank 89
The program will allow the teacher to add student scores, delete student scores, and display all student scores. All of this information must be maintained in the student_scores.txt file so that the teacher can access this information at any time; even after the application has closed. Your program must contain a menu and three additional functions to the main; addStudentScores(), deleteStudentScores(), and displayStudentScores.
(1) Display a program header and the user menu to allow the user to make a menu selection. The program must repeat until the user selects option 4 to exit the program.
Ex.
Student Test Score Entry Program
--------------------------------
1. Add Student Score
2. Delete Student Score
3. Display Student Scores
4. Exit Program
Enter Selection:
4
The program will now exit!
(2) Write an addStudentScores() function that allows the teacher to add any number of student scores to the file. The program should ask the teacher how many student scores to enter, then append the text file with the appropriate number of student test scores. A confirmation message should also appear to confirm that the new student scores have been added to the file. Note that all new scores must follow the same format that already exists in the text file with the student name and test score on the same line.
Ex.
Student Test Score Entry Program
--------------------------------
1. Add Student Score
2. Delete Student Score
3. Display Student Scores
4. Exit Program
Enter Selection:
1
Number of student scores to enter:
2
Enter student's name:
Mary
Enter student's test score:
97
Enter student's name:
Brian
Enter student's test score:
79
New test scores saved to file!
(3) Write a deleteStudentScores() function that allows a teacher to enter only the name of a student and have that student and his or her score deleted from the file. A message of Student not found! should be displayed if the teacher enters a name of a student not in the text file. Or a message of [StudentName] has been deleted from the file! should be displayed to confirm that the student has been deleted from the text file.
Hints:
Ex.
Student Test Score Entry Program
--------------------------------
1. Add Student Score
2. Delete Student Score
3. Display Student Scores
4. Exit Program
Enter Selection:
2
Enter the student's name to delete:
Ronald
Student not found!
1. Add Student Score
2. Delete Student Score
3. Display Student Scores
4. Exit Program
Enter Selection:
2
Enter the student's name to delete:
Sarah
Sarah has been deleted from the file!
(4) Write a displayStudentScores() function that allows the teacher to display all of the student scores in the text file.
Ex.
Student Test Score Entry Program
--------------------------------
1. Add Student Score
2. Delete Student Score
3. Display Student Scores
4. Exit Program
Enter Selection:
3
Student Scores
--------------
James 88
Ronda 92
Benjamin 85
Frank 89
Mary 97
Brian 79