Build code to ask the user to enter course code and quota

Assignment Help Python Programming
Reference no: EM132355798

Question

Having the hardest time with this, any help/explanation greatly appreciated!

Design a Python project manage_course. Add a Python file course.py to this project.

Define a class Course in this file. This class has three publicly accessible instance variables to store course code, quota and enrollment.

Define the following methods:

(a) An __init__ method that accepts the course code and quota as arguments. Write statements in __init__ to store them in instance variables. Also form an instance variable to store enrollment and initialize it to 0.

(b) An add_student method to increase enrollment by one and display "One student added" if the course is not full. If the course is already full, make no change to enrollment and display "Course already full". This method has no argument other than self and has no return value.

(c) A drop_student method to decrease enrollment by one and display "One student dropped" if the course is not empty. If the course is empty, make no change to enrollment and display "Course is empty". This method has no argument other than self and has no return value.

The following class diagram shows the design of this class:

Course

+course code: String

+quota: Integer

+enrollment: Integer

+create(code:String, quota:Integer)

+add_student()

+drop_student()

Add a file manage_course_main.py to this project. This is the main module. Build code to ask the user to enter course code and quota of a course.

Use the data provided by the user to put together an instance of Course.

Design a loop to manage this course. In the loop, ask the user to enter 1 for adding a student, 2 for dropping a student, 3 for displaying course info, or 0 for exit.

If 1 is chosen, call the add_student method of the Course object and use a print statement to display updated enrollment.

If 2 is chosen, call the drop_student method of the Course object and use a print statement to display updated enrollment. If 3 is chosen, display values stored in the Course object to show course code, quota and enrollment.

The following shows a sample test run:

Enter course code: CSC121

Enter course quota: 3

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 2

Course is empty.

Enrollment: 0

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 1

One student added.

Enrollment: 1

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 1

One student added.

Enrollment: 2

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 1

One student added.

Enrollment: 3

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 1

Course already full.

Enrollment: 3

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 2

One student dropped

Enrollment: 2

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 3

Course code: CSC121

Quota: 3

Enrollment: 2

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 0

Reference no: EM132355798

Questions Cloud

Calculate the year in which both funds : You have inherited $50,000 and want to invest for retirement. Alice, your close friend working at a local investment bank shared with you two products available
Discuss the major components of the sarbanes-oxley act : Discuss the major components of the Sarbanes-Oxley Act of 2002 and Corporate Governance?
What is the aftertax cost of debt : What is the company's pretax cost of debt? If the tax rate is 21 percent, what is the aftertax cost of debt?
Coverage ratio and debt service coverage ratio : Calculate interest coverage ratio and debt service coverage ratio. Show math work please.
Build code to ask the user to enter course code and quota : Design a loop to manage this course. In the loop, ask the user to enter 1 for adding a student, 2 for dropping a student, 3 for displaying course info.
Component cost of debt for use in the wacc calculation : Kenny Electric Company's noncallable bonds were issued several years ago and now have 20 years to maturity. These bonds have a 9.25%
Best price movement potential : The market rate of interest (discount rate) is 8 percent. Which bond has the best price movement potential? Use duration to answer the question.
We have personal expenses along with micro expenses : We have personal expenses along with micro expenses. People don't realize that micro expenses so add up if you look at it on weekly or monthly basis.
Required rate of return : If Stock A's beta were 1.8, then what would be A's new required rate of return? Round your answer to two decimal places.

Reviews

Write a Review

Python Programming Questions & Answers

  Would have to be applied before x was no longer a fraction

Verify your answer to part a by writing a short Python function called strange17, taking n as its argument.

  Write a Python script for the ice cream ordering system

Assignment: Below Zero - ice cream store. In this first part of Task, you should write a Python script for the ice cream ordering system

  Write a program that translates a letter grade into a number

Write a program that translates a letter grade into a number grade. Letter grades are A, B, C, D, and F, possibly followed by + or -.

  What good are movie ids and ratings

Implement a function called topRated(). The function will take a file name as a parameter and return a sorted list - What good are movie IDs and ratings? You want to know the actual title of the movie! Implement a function called getTitles(). The fu..

  Describe the original data for the city you are observing

Describe the original data for the city you are observing. Regression Analysis Hypothesis testing. Explain the hypothesis and the result by graph.

  Write an expression that concatenates the string

Write an expression that concatenates the String variable suffix onto the end of the String variable prefix .

  Assignment brief you are tasked with improving the code for

assignment brief you are tasked with improving the code for the haunted house game. please read the associated hand-out

  Write appropriate accessor and mutator methods

Design a class that holds the following personal data: name, address, age, and phone number. Write appropriate accessor and mutator methods.

  Look up terms in a tech dictionary

Create a program that allows a user to look up terms in a tech dictionary - programming or scripting that is of interest to you, and complete one or more web-based tutorials on the topic.

  Output the starting position and length

X Strings: Input a string. Output the starting position and length of the first occurrence of the longest substring of capital Xs in that string. The first letter is in position 1.

  Find all of the different stores that are in the central

How would i find all of the different stores that are in the 'central' district?.

  In the constructor supply the height and radius of the can

Implement a class SodaCan with methods getSurfaceArea() and getVolume(). In the constructor, supply the height and radius of the can.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd