1. Ask for 2 numbers
2. Calculate how many multiples there are between the 2 numbers entered
A. How many multiples of 3 are there
B. How many multiples of 5 are there
3. Output the results
==========================================
Solution
Test 1
Enter two integers: 1 3
Multiples of 3 between 1 and 3: 1
Multiples of 5 between 1 and 3: 0
Test 2
Enter two integers: 100 5000
Multiples of 3 between 100 and 5000: 1633
Multiples of 5 between 100 and 5000: 981
Test 3
Enter two integers: 50 2
Multiples of 3 between 2 and 50: 16
Multiples of 5 between 2 and 50: 10
Test 4
Enter two integers: 451 21345
Multiples of 3 between 451 and 21345: 6965
Multiples of 5 between 451 and 21345: 4179
Test 5
Enter two integers: 3 3
Multiples of 3 between 3 and 3: 1
Multiples of 5 between 3 and 3: 0
Test 6
Enter two integers: 5 5
Multiples of 3 between 5 and 5: 0
Multiples of 5 between 5 and 5: 1
Wednesday, February 28, 2018
Chapter 4 Homework Conditions and Test Results
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
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
Tuesday, February 27, 2018
Subscribe to:
Posts (Atom)