1. Ask for the Bill Amount
2. Ask for the Amount being paid
3. Calculate what the amount being paid compares to the balance for credits and penalties
A. If you pay in full, you get either $10 or 1% credit(whichever is smaller)
B. If you pay at least 50% of the Bill, a 5% penalty is applied to the remaining balance.
C. If you pay at least 20% and less than 50% of the Bill, a 10% penalty is applied to the remaining balance.
D. If you pay any other balance amount of the Bill, a 20% penalty is applied to the remaining balance.
4. Calculate the output results and present to the user
A. Penalties or Credit if applicable
B. Remaining Balance
===============================================
Solution
Test 1
Enter the billing amount: 500
Enter the payment amount: 500
Thank you for paying the full amount.
You will receive $5.00 credit on your next bill.
Test 2
Enter the billing amount: 500
Enter the payment amount: 600
The penalty added to the next bill is: $-5.00
The unpaid balance including the penalty is: $-105.00
Test 3
Enter the billing amount: 50
Enter the payment amount: 10
The penalty added to the next bill is: $4.00
The unpaid balance including the penalty is: $44.00
Test 4
Enter the billing amount: 5000
Enter the payment amount: 25
The penalty added to the next bill is: $995.00
The unpaid balance including the penalty is: $5970.00
Test 5
Enter the billing amount: 500
Enter the payment amount: 251
The penalty added to the next bill is: $12.45
The unpaid balance including the penalty is: $261.45
No comments:
Post a Comment