Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

print('Welcome user to the Grade Calculator Version 2.0. I thank you for continuing support for this program. This allows us to continue focusing on making

print('Welcome user to the Grade Calculator Version 2.0. I thank you for continuing support for this program. This allows us to continue focusing on making apps you will love. Thanks.')

studentsName = [""] * (10) grade = [""] * (10) credts = [0] * (10) hours = [0] * (10) creditSum = 0 avgHours = 0

MinHours = { "A": 15, "B": 12, "C": 9, "D": 6, "F": 0 } #creating a class for student information class Student: def __init__(self, name, employee_id, department, credits, desired_grade): self.name = name self.employee_id = employee_id self.department = department self.credits = credits self.desired_grade = desired_grade self.study_hours = MinHours[desired_grade] * credits

def __str__(self): return f"{self.name}, Credits: {self.credits}, Study Hours: {self.study_hours}, Grade: {self.desired_grade}"

#creating class to represent the report with all desired information.

class Report: def __init__(self, creator, employee_id, department, report_for, report_employee_id, report_department): self.creator = creator self.employee_id = employee_id self.department = department self.students = [] self.report_for = report_for self.report_department = report_department self.report_employee_id = report_employee_id

def add_student(self, student):#adds a student to the list of students self.students.append(student)

def display_report(self): total_credits = 0 total_study_hours = 0

for student in self.students: total_credits += student.credits total_study_hours += student.study_hours average_credits += total_credits / len(self.students) average_study_hours = total_study_hours / len(self.students)

print("Study Hours Report")#display report print(f"Created for {self.report_for}, {self.report_employee_id}") print(f"Department:{self.report_department}") print(f"Created By:{self.creator}, {self.employee_id}") print(f"Department: {self.department}") print(f"Total Students: {len(self.students)}") print(f"Average Credits: {average_credits:.2f}") print(f"Average Study Hours: {average_study_hours:.2f}")

def create_report():#get user information creator_name = input("Enter your name:") creator_employee_id = input("Enter your employee id:") creator_department = input("Enter your department:") report_for = input("Enter the name of the report the person is for:") report_employee_id = input("Enter the employee id of the person the report is for:") report_department = input("Enter the department of the person the report is for:")

report = Report(creator_name, creator_employee_id, creator_department, report_for, report_employee_id, report_department)

with open("HowManyHours.txt", "r") as file: lines = file

def determineHours(self):#reads data from the StudyHours.txt file, creates an object for each entry, and displays the information, eventually writing the data to HowManyHours.txt #opening StudyHours.txt in read mode with open ("StudyHours.txt", "r") as file1: data = file1.readlines() correct_errors(data)#reading in data and correcting any errors. total_study_hours = 0

for record in data: credits = int(record['credits']) grade = record['grade']

if grade == 'A':#determine weekly study hours based on desired grade study_hours = 15 * credits elif grade == 'B': study_hours = 12 * credits elif grade == 'C': study_hours = 9 * credits elif grade == 'D': study_hours = 6 * credits elif grade == 'F': study hours == 0 else: print("Invalid grade for student {record['name']})

total_study_hours += study_hours#add study hours to total print(f"Total Study Hours: {total_study_hours}")#display total number of weekly study hours with open ("HowManyHours.txt", 'a') as file:#append the data alphabetically data.sort(key=lambda x: x['name'])#sort data by name

for record in data:#write data to file name = to_proper_case(record['name']) credits = record['credits'] study_hours = total_study_hours grade = record['grade'] file.write(f"{name} {credits} {study_hours} {grade} ")

This is the code I have for "option a". I need to make sure it comes out as the below:

Select Option A to determine the hours for study:

Select Option B to determine the grade:

Select Option C to determine the average credits, average study hours and total

students who used the program:

A

FullName: Aaron Rodgers

Grade: A

Credits: 12

WeeklyStudyHours: 60.0

You entered

K which is an incorrect value for the entered Grade

Please enter the desired grade such as A for an A:

A

FullName: Tom Brady

Grade: A

Credits: 9

WeeklyStudyHours: 45.0

FullName: Philip Rivers

Grade: c

Credits: 3

WeeklyStudyHours: 9.0

FullName: Joe Theismann

Grade: B

Credits: 15

WeeklyStudyHours: 60.0

FullName: Paul Revere

Grade: B

Credits: 15

WeeklyStudyHours: 60.0

FullName: Akbar Habib

Grade: A

Credits: 12

WeeklyStudyHours: 60.0

FullName: Steven Universe

Grade: B

Credits: 9

WeeklyStudyHours: 36.0

FullName: Barack Obama

Grade: C

Credits: 6

WeeklyStudyHours: 18.0

FullName: Harold Jenkins

Grade: A

Credits: 12

WeeklyStudyHours: 60.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

3 > O Actual direct-labour hours Standard direct-labour hours...

Answered: 1 week ago