Project 6: Database

Rhodes College needs you to write a program to help the registrar manage their student database. You will be creating a program that reads in a database of students and their majors from a file, then lets the user perform various operations on the database.

How the program should work

Write a program that reads in the contents of the file database.txt, whose file format is described below. Then, let the user choose from the following operations: The program should keep running until the user wants to quit.

The database file format

The database.txt file contains one line per student. Each line consists of the student's first name, followed by a space, followed by their major. Neither the name nor the major will have any spaces in them. You can download database.txt, or get it from my public folder.

Sample interaction

What the user types is in bold, and brackets describe what the program is doing.
[program begins, reads database.txt, and stores that information away]
1. Add a new student
2. Print all students
3. Print all majors
4. Look up a student's major
5. Quit
Choose an option: 2
All students:  ['Joseph', 'Sally', 'Martha', 'Quentin', 'Patricia', 'Emma', 'Miguel']

1. Add a new student
2. Print all students
3. Print all majors
4. Look up a student's major
5. Quit
Choose an option: 3
All majors:  ['Biology', 'Chemistry', 'Physics', 'CompSci', 'Art', 'ArtHistory']

1. Add a new student
2. Print all students
3. Print all majors
4. Look up a student's major
5. Quit
Choose an option: 4
What is the student's name? Sally
Sally is majoring in Chemistry.

1. Add a new student
2. Print all students
3. Print all majors
4. Look up a student's major
5. Quit
Choose an option: 4
What is the student's name? Mark
Student not found.

1. Add a new student
2. Print all students
3. Print all majors
4. Look up a student's major
5. Quit
Choose an option: 1
What is the new student's name? Mark
What is the new student's major? CompSci

1. Add a new student
2. Print all students
3. Print all majors
4. Look up a student's major
5. Quit
Choose an option: 4
What is the student's name? Mark
Mark is majoring in CompSci.

1. Add a new student
2. Print all students
3. Print all majors
4. Look up a student's major
5. Quit
Choose an option: 5
Done.
[program ends]

Hints

Try these steps:

Extra credit

Add in an option to print all of the students who are majoring in a given subject. For instance, the user could type in Biology and the program would report that Joseph and Quentin are majoring in Biology.

What to turn in

Through Moodle, turn in your code as a file called database_yourLastName_yourFirstName.py.