Comp102 Practical 1
Comp102 Practical 1
Comp102 Practical 1
𝐴 = 𝑃 (1 + 𝑟𝑡)
where:
• 𝐴 is the final amount,
• 𝑃 is the initial principal amount,
• 𝑟 is the annual interest rate,
• 𝑡 is time in years.
Write a program that prompts the user to enter the initial amount, interest rate and
time. The program must then calculate the final amount and display it to the user.
1
Question 4: Currency Breakdown
Write program that prompts a user for an amount in Rands, and then breaks it down
into the corresponding Rand denominations with counts.
For example, if the amount R1 274,01, the program should output:
Output
Two hundreds: 6
One hundreds: 0
Fifties: 1
Twenties: 1
Tens: 0
Coins: 4
Cents: 1
Note that the coins are only broken down into cents and other coins, e.g. R1, R2, R5
are grouped into a coins bucket and all cent coins, e.g. 2c, 5c; are grouped into a
cents bucket.
-