Exam 2 - Updated

.docx

School

University of Texas, Rio Grande Valley *

*We aren’t endorsed by this school

Course

1380

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

3

Uploaded by keylym07

Report
CSCI 1380 Yessenia Rodriguez Name: _______________________ Exam 2 Write a menu-drive program that allows the user to do the following: a) Add a student to the class roster. b) Find a student in the class roster. c) Create a grade report for a given class and score. The program should use a module that consists of at least the following functions: def printMenu() – displays the menu for the program def addStudent(name, file_roster) – the name of the student the user wished to add and the filename for the file with the class roster are given as arguments. If the student’s name (name) is not found in the class roster, the name should be added to the end of file_roster. If it is found, the function should display a message informing the user the student was already in the roster. def findStudent(name, file_roster) – the name of the student the user wishes to search for and the filename for he file with the class roster are given as arguments. If the student’s name (name) is found in the class roster, the function returns the line number the name was found in the file file_roster. If it is not found, the function returns -1. def createReport(file_roster, file_scores, report_name) – the filenames for the files with the class roster and students’ grades are given as arguments; additionally, the name for the report generated is also given. The function generates a grade report that contains a calculated average (use calcAverage function), the lowest grade, and the highest grade for the class. If there are more students than grades provided, the list of students pending the assignment (students with no grade, “extra” students) will be provided in the report. If there are more grades than students, a warning should be provided in the report to warn the user the data generated may be incorrect due to the discrepancy. def calcAverage(file_scores) – the filename for the file with the students’ grades is given as an argument. The function calculates and returns the average of all the grades in the file file_score minus the lowest score (uses the findLowest function). def findLowest(file_scores) – the filename for the file with the students’ grades is given as an argument. The function returns the lowest score in the file file_score. def findHighest(file_scores) – the filename for the file with the students’ grades is given as an argument. The function returns the highest score in the file file_score.
CSCI 1380 Yessenia Rodriguez Here is an example of the contents of the input file class_roster.txt before the program was executed: Here is an example of the contents of the input file scores.txt : Here is an example of the contents of the output file, which was called Exam_1_report.txt based on the name entered:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help