Create a test plan with sample data for the following proble

Create a test plan with sample data for the following problem. You do not have to write a code and calculate expected results, but please explain why each test case was chosen as related to the problem. Also include a description of any error checking on the input values that you should do. Given an amount of change less than 100 cents, find the minimum number of coins (quarter = 25 cents, dime = 10 cents, nickel = 5 cents, penny = 1 cent).

Solution

Test Plan:
1. Read in the number of cents.
2. if cents > 100 or less than 0, //This is error checking.
print some error message, and stop execution.
3. numOfQuarters = cents / 25   //This will make as many quarters as possible.
cents = cents % 25           //This will just save the remaining cents.
4. numOfDimes = cents / 10       //Of the remaining cents, make as many dimes as possible.
cents = cents % 10           //This will just save the remaining cents.
5. numOfNickels = cents / 5       //Of the remaining cents, make as many nickels as possible.
cents = cents % 5           //This will just save the remaining cents.
6. pennies = cents.               //The remaining cents should be paid as pennies.

Consider an example:
100 cents.
This is a valid number of cents.
When applied step 3.
numOfQuarters = 100 / 25 = 4. So, 4 quarters are made.
cents = 100 % 25 = 0. So, all the cents has been exhausted.
When applied step 4.
numOfDimes = 0 / 10 = 0. So, no dimes.
The same happens for nickels and pennies.
So, the change could be made is 4 quarters.

Consider another example:
-5 cents.
This is an invalid number of cents.
So, step 2 fails. It prints a message and will stop executing.

Consider one more example:
49 cents.
This is a valid number of cents.
When applied step 3.
numOfQuarters = 49 / 25 = 1. So, 1 quarter could be made.
cents = 49 % 25 = 24. So, remaining cents is 24.
When applied step 4.
numOfDimes = 24 / 10 = 2. So, 2 dimes could be made.
cents = 24 % 10 = 4. So, remaining cents is 4.
When applied step 5.
numOfNickels = 4 / 5 = 0. So, no nickels.
cents = 4 % 10 = 4. So, still left with 4 cents.
When applied step 6.
pennies = 4. So, 4 pennies.

Therefore, the change made is: 1 quarter, 2 dimes, and 4 pennies.

 Create a test plan with sample data for the following problem. You do not have to write a code and calculate expected results, but please explain why each test

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site