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

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

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