Assignments - PROG12583 Prog Foundations - Python

pdf

School

Sheridan College *

*We aren’t endorsed by this school

Course

12583

Subject

Computer Science

Date

Dec 6, 2023

Type

pdf

Pages

3

Uploaded by GrandDangerRaven31

Report
11/29/23, 2:47 PM Assignments - PROG12583 Prog Foundations - Python https://slate.sheridancollege.ca/d2l/le/content/1137143/viewContent/14720654/View 2/5 Assignment 4 Assignment Requirements 1. In a module named course.py , create a class called Course that a college might use to represent a course it offers to its students. The UML class diagram is given below: Course course_code course_name num_of_students tuition_fee __init__(course_code, course_name, num_of_students=0, tuition_fee=0) get_course_code() set_course_code(course_code) get_course_name() set_course_name(course_name) get_num_of_students() set_num_of_students(num_of_students) get_tuition_fee() set_tuition_fee(tuition_fee) get_tuition_total() __str__() Notes: As shown in the class diagram above, the class Course must contain four attributes, the corresponding accessors and mutators (get and set methods). The mutators for num_of_students and tuition_fee should raise an exception if their values passed are set to be negative. The class must also contain a method that calculates the total tuition amount collected from all students (i.e., multiplies the num_of_students by the tuition_fee), then returns the amount. Finally, Course class must also contain a __str__() method that returns a formatted string with the information of a course object. This method will be used in the application class to display the output as shown in the examples below. Note: DO NOT include in the __str__ method the header shown in the example. That part is from the application class. Including the header in the string returned by __str__ method would make the method non-generic. 2. Write a test app named course_app.py that uses (imports course module) Course class to create objects and uses different functions and exception handling techniques to perform the following: 1. Prompts to, and receives from the end user String values such as the course code and course name. 2. Prompts to, and receives from the end user int values for the number of students. 3. Prompts to, and receives from the end user float values for the tuition fee. Use exception handling to display appropriate messages if the user enters negative or non number values for the number of students or tuition fee Listen
11/29/23, 2:47 PM Assignments - PROG12583 Prog Foundations - Python https://slate.sheridancollege.ca/d2l/le/content/1137143/viewContent/14720654/View 3/5 non-number values for the number of students or tuition fee. 4. Prints out the course information. Note: course_app.py must contain multiple functions as described above. Writing the code inside the main function, or without functions at all, will result in mark deductions. Example of Interaction and Output Program Prompts are in blue , User Input is in red , Program Output is in black Output Sample 1: Enter course code: PROG12583 Enter course name: Python Enter number of students: 159 Enter tuition fee: 928.78 ----------------------------------------------------- Course Code Course Name Students Fee Total ----------------------------------------------------- PROG12538 Python 158 928.78 146,747.24 Output Sample 2: Enter course code: PROG12583 Enter course name: Python Enter number of students: -158 Error: Number of students must be positive! Output Sample 3: Enter course code: PROG12583 Enter course name: Python Enter number of students: 158 Enter tuition fee: -928.78 Error: Tuition fee must be positive! Output Sample 4: Enter course code: PROG112583 Enter course name: Python Enter number of students: a invalid literal for int() with base 10: 'a' Output Sample 5: Enter course code: PROG12583 Enter course name: Python Enter number of students: 158 Enter tuition fee: a could not convert string to float: 'a' Other Requirements This assignment is to be done individually; you are not allowed to work on this assignment with anyone. See also the Academic Honesty Policy for more details. Copied assignments will be subject to regulations against academic integrity. All assignments are subject to a late penalty of 10% per day (including weekends). Late assignments will only be accepted up to 3 days after the due date (including weekends). Submission
11/29/23, 2:47 PM Assignments - PROG12583 Prog Foundations - Python https://slate.sheridancollege.ca/d2l/le/content/1137143/viewContent/14720654/View 4/5 Submission Follow these instructions carefully or you risk penalties up to 100% of your grade. Your submission must follow all the submission requirements outlined in the Submission Standards . All assignments must be submitted in plain text format (.txt). No other types of files will be accepted for submission. make sure that when passing the code onto your text editor, the indentations and spaces are preserved. Once you have finished your assignment and you are ready for submission, copy and paste the entire code from both python files in a single text file. Name the text file YourNameAssignment4.txt and upload it in the Assignments drop box in SLATE. Evaluation Your submission will be evaluated based on the following criteria: Criteria Deductions Mark Functionality 6 - The program prompts as it is shown in the examples 2 - Program displays the correct output and it is properly formatted 2 - The program displays the result as shown in the examples 2 Course Class 13 - Attributes are valid identifiers and are set as private. 1 - Class contains the initializer and it sets the default values and raises exceptions. 3 - Class contains accessors and mutators for all of the attributes. 2 - Mutators for numeric attributes raise exceptions to reject non positive values. 2 - Class contains a method for calculating the total tuition. 2 - The __str__() method returns a formatted string. 3 Course App 11 - The app is written in a seprate file and uses import statement to use Course class. 2 - The app uses returning value functions to prompt the user for input. 4 - Exceptions raised in by the mutators in Course class and Python functions are handled. 3 - Printing is done in a separate method that prints the results as shown in the examples. 2 Penalties for not following requirements - Course class contains unnecessary attributes/methods (-2 marks per occurrence) Penalties for Violating Programming Standards/Conventions
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help