Question: Write a program that reads from a text file students.txt student information of a given class and stores them into a list of dictionaries. Each

Write a program that reads from a text file "students.txt" student information of a given class and stores them into a list of dictionaries. Each line of the file contains a student id (integer), a student name, a student gpa (float), and the number of completed credits (integer). The program should then display the menu shown below allowing the user to select repeatedly an option until he or she chooses to quit:

P: Print the student information (name. id, gpa and credits) ofall students sorted in alphabetic order of their names

F: Find and display student information for a given student id (the user enters the student id)

L: List all the information ad. gpa and credits) of all students under probation (i.e. gpa < 2.0)

D: Delete the student information for a given student id (the user enters the student id)

E: Exit the program after saving into the file “student:txt” the modifications made during the session

Your program must define and use at least the following functions with suitable parameters:

1. readStudentInfo (...): reads the student information from the input file and stores It in the list of dictionaries. Note that the information in the file is in increasing order of student id.

2. Menu (...): displays the menu and returns the user's choice

3. FindStudent (...): returns the position (index) of the student with given id, in the complex structure if found otherwise it returns -1.

4. DeleteStudentInfo (...): deletes from the complex structure the information of a student with the given id. If the given student Id is not found, it prints an error message and does not make any changes. This function should use a binary search algorithm when searching for the student id.

5. PrintStudentinfo (...): prints all students' information in a tabular format.

6. SaveStudentInfo(...): saves back the modified students' information into the file students.txt. The students should be stored in increasing order of their id.

Additional Requirements:

1. You should display error message whenever it's possible

2. You should answer the following question: Could you use any of the following structures instead of a list of dictionaries. If no, why? If yes, indicate its advantages/disadvantages compared to a list of dictionaries?

a) A list of sets

b) A list of lists

c) Parallel lists

Step by Step Solution

3.41 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Certainly Ill walk you through solving the problem in steps detailing both the theoretical and pract... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (2 attachments)

PDF file Icon

60950e6a74dfd_25502.pdf

180 KBs PDF File

Word file Icon

60950e6a74dfd_25502.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!