Question: For this lab you will create a new program that creates a class named Student that contains the following data about a student: Name Student

For this lab you will create a new program that creates a class named Student that contains the following data about a student:

Name

Student ID number

GPA

Expected grade in this course

Full time or part time.

Create five student objects from this class and pass data to fill in the class data above. Besides creating the object, you will write a menu-driven program that performs the following tasks:

Look up and print the student GPA

Add a new student to the class

Change the GPA of a student

Change the expected grade of a student

Print the data of all the students in a tabular format

Quit the program

Save all the files that you created in this program with appropriate file names.

###########################

This is what I have so far, I can't seem to make it work. Not sure what I am doing wrong. Need all the help I can get!!

class Student:

def __init__(self): self.name = str(raw_input("What is the name of the student? ")) self.id_number = int(raw_input("What is the i.d. number of " + self.name + "? ")) self.gpa = float(raw_input("What is " + self.name + "'s GPA? ")) self.expected_grade = int(raw_input("What is the expected grade of " + self.name + "? ")) self.work_status = str(raw_input("Does " + self.name + " work full-time or part-time? ")) menu = str("1. Look up and print the student GPA." + ' ' + "2. Add a new student to the class." + ' ' + "3. Change the GPA of a student." + ' ' + "4. Change the expected grade of a student." + ' ' + "5. Print the data of all the students in a tabular format." + ' ' + "6. Quit the program. ")

student_list = []

def display_students(self): Student.student_list.sort() print("") for n in Student.student_list: print(n) print("")

def display_student_info(self): Student.student_list.sort() print("Name\tI.D. #\t\tGPA\t\tExpected Grade\t\tEmployment") print("----------------------------------------------------------") for name in Student.student_list: print(name, '\t', getattr(name, "id_number"), '\t', getattr(name, "gpa"), '\t', getattr(name, "expected_grade"), '\t', getattr(name, "work_status"))

def menu_selection(self): valid_input = False user_input = int(input()) while valid_input == False: try: if int(user_input) not in range(1, 6): raise ValueError else: valid_input = True except ValueError: print("You have entered an invalid selection for the menu. Please enter a number from 1 to 6. ") user_input = int(input(str())) # Look up and print student GPA if user_input == 1: Student.display_students(self) name = str(raw_input("Which student would you like to look up the GPA for? ")) print(name + ": " + getattr(self.name,"gpa")) # Add a new student to the class if user_input == 2: print("") print("Okay. Let's add a new student to the class. ") Student.__init__(self) Student.student_list.append(self.name) # Change the GPA of a student if user_input == 3: print("") print("Okay. Let's change the GPA of a student in the class.") self.display_students() name = str(raw_input("Which student's GPA would you like to change? ")) new_gpa = str(raw_input("What would you like " + name + "'s new GPA to be? ")) setattr(self.name, self.gpa, new_gpa) # Change the expected grade of a student if user_input == 4: print("") print("Okay. Let's change the expected grade of a student.") print("Which student's expected grade would you like to change? ") self.display_students() name = str(raw_input("Which student's expected grade would you like to change? ")) new_expected_grade = float(raw_input("What would you like " + name + "'s new expected grade to be? ")) setattr(Student, str(slef.expected_grade), new_expected_grade) # Print the data of all the students in a tabular format if user_input == 5: print("") print("Okay, here is all the data for the currently entered students: ", ' ') Student.display_student_info(self) # Quit the program if user_input == 6: print("") print("Okay. Now quitting the program.") quit()

def main(): count = 0 while count < 5: count += 1 print("Now that the students information has been entered, you can select from the menu below to alter student data or quit the program." + ' ' + "Please make a selection: " + ' ') s= Student() print(s.menu) s.menu_selection()

main()

This is to be done in python! Please show indentation. Thanks a lot!!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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

Students Have Also Explored These Related Databases Questions!