Write a menu driven program with the following options: Before start showing the
ID: 3580569 • Letter: W
Question
Write a menu driven program with the following options: Before start showing the menu options, you have to make a file which contains data of some students' ids and grades using appropriate format. The number of lines of the file is unknown. First task is to store the data in two parallel arrays (arr_ids, arr_grades). Make the ids array of type long to handle large integer values. Then the program will show a menu of choices as following: Add a grade (read the id, grade from the user). The program will add the grade and id only if the entered id does not exist already among the id's present in the array. If it exists, the program shall inform the user by showing an appropriate message. (Assume that each id has only one grade, so duplicated id is not allowed). Find a grade given an id (i.e. your program will read the id from the user and find the corresponding grade to display it). Delete a user from the 2 arrays given the relevant id (so you have to delete both: id and grade from the array). find the highest three grades and print them with the corresponding ids. Find the lowest three grades and print them with the corresponding ids. Finds the average of grades and display it on the screen. Find grades which are greater than the average and print them with the corresponding ids. Find the max grade among students and print its id with the corresponding grade. Find the min grade among students and print its id with the corresponding grade. Save (write) the id's and grades after the updates you have done previously in a file using the same format used in the original data file. Print the 2 arrays on the screen using the same format of the data file. Practice modular programming by writing functions whenever possible. Follow the convention concerning variable names. Insert comments wherever needed. -The deadline for submitting the project is the last week of classes. - Your program must contain as irony functions as needed. You need to divide your problem into small tasks and each task handled by a function. - The source code will contain the comments on the different functions. - You need also to include snap shots of the execution of your program showing the different phases of the execution - Each project will be done by 2 students, but each student has to know about the entire project.Explanation / Answer
def readData(fileName):
grades = []
ids = []
line = readByLine(fileName).split(",")
grades.append(line[0])
ids.append(line[1])
def addGrade(ID, grade, ids, grades):
if ID not in ids:
ids.append(ID)
grades.append(grade)
else:
print "ID is already present"
def findGrade(ID, grades, ids):
index = ids.indexOf(ID)
return grades[index]
def deleteUser(ID, grades, ids):
index = ids.indexOf(ID)
ids.remove(ID)
grades.remove(index)
def highestGrades(ids, grades):
grades.sort()
print grades[0], grades[1], grades[2]
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.