100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

COS1512 Assignment 2 2023 (762913)

Rating
-
Sold
-
Pages
26
Grade
A+
Uploaded on
28-06-2023
Written in
2022/2023

QUESTIONS WITH ANSWERS











Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
June 28, 2023
Number of pages
26
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Content preview

6/28/2023




COS1512
Assignment 2
2023 (762913)
Questions with answers




Schoeman, Marthie
[COMPANY NAME]

, COS1512 Assignment 2 2023 (762913)


DUE DATE: 3 July 2023
CUT-OFF DATE: 6 July 2023

TUTORIAL MATTER: Chapters 4, 5, 6, 8 and 9 of the Study Guide
Chapters 4 (section 4.6), 5 (section 5.5), 6, 8 and 9
(excluding the optional parts of section 9.2) of
Savitch

WEIGHT: 30%
MARKS: 70




Question 1
Write a program to determine the tuition fees for a student. The program should
use two overloaded functions, each named calcFees, to determine the tuition
fees for a student. Students who repeat a module pay a different fee for the
modules which are repeated. The program should first ask if the student repeats
any modules. If the student repeats, the program should ask for the number of
modules which are repeated.
One of the overloaded functions should accept the number of modules enrolled
for the first time and the fee for those modules as arguments (parameters), while
the other function accepts arguments for the number of modules enrolled for
the first time and the fee for those modules as well as the number of modules
repeated and the fee for those modules. Both functions should return the tuition
fees for the student.
python
Copy code
def calcFees(num_modules, fee):
return num_modules * fee

, def calcFees(num_modules_first_time, fee_first_time, num_modules_repeated,
fee_repeated):
return (num_modules_first_time * fee_first_time) + (num_modules_repeated
* fee_repeated)


repeat_modules = input("Are there any modules being repeated? (yes/no): ")


if repeat_modules.lower() == "yes":
num_modules_first_time = int(input("Enter the number of modules enrolled
for the first time: "))
fee_first_time = float(input("Enter the fee for modules enrolled for the first
time: "))
num_modules_repeated = int(input("Enter the number of modules repeated: "))
fee_repeated = float(input("Enter the fee for repeated modules: "))


total_fees = calcFees(num_modules_first_time, fee_first_time,
num_modules_repeated, fee_repeated)
else:
num_modules_first_time = int(input("Enter the number of modules enrolled:
"))
fee_first_time = float(input("Enter the fee for modules enrolled: "))


total_fees = calcFees(num_modules_first_time, fee_first_time)


print("Total tuition fees: $" + str(total_fees))
In this program, there are two overloaded calcFees functions. The first function
calcFees(num_modules, fee) calculates the tuition fees for a student who doesn't
repeat any modules. The second function calcFees(num_modules_first_time,
fee_first_time, num_modules_repeated, fee_repeated) calculates the tuition fees
for a student who repeats modules.

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
smillanih Chamberlian School of Nursing
View profile
Follow You need to be logged in order to follow users or courses
Sold
398
Member since
2 year
Number of followers
327
Documents
1239
Last sold
6 days ago

3,7

43 reviews

5
23
4
3
3
5
2
5
1
7

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions