100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
COS1512 Assignment 2 2023 (762913) R53,43   Add to cart

Exam (elaborations)

COS1512 Assignment 2 2023 (762913)

 1 view  0 purchase

QUESTIONS WITH ANSWERS

Preview 3 out of 26  pages

  • June 28, 2023
  • 26
  • 2022/2023
  • Exam (elaborations)
  • Questions & answers
All documents for this subject (34)
avatar-seller
inotes
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.

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through EFT, credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying this summary from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller inotes. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy this summary for R53,43. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

78600 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy summaries for 14 years now

Start selling
R53,43
  • (0)
  Buy now