##### Differences

This shows you the differences between two versions of the page.

 cs-142:cougar-cash-with-input-validation-and-user-confirmation [2015/05/11 14:52]cs142ta created cs-142:cougar-cash-with-input-validation-and-user-confirmation [2015/05/12 13:12]cs142ta 2015/05/12 13:12 cs142ta 2015/05/11 14:53 cs142ta 2015/05/11 14:52 cs142ta created Next revision Previous revision 2015/05/12 13:12 cs142ta 2015/05/11 14:53 cs142ta 2015/05/11 14:52 cs142ta created Line 5: Line 5: *The initial card balance is$10.00. *The initial card balance is$10.00. *Any purchase greater than what is on the card should use up the balance on the card. *Any purchase greater than what is on the card should use up the balance on the card. - ===Additions from [[Cougar Cash]]=== + ===Additions from Cougar Cash=== *Check whether the input from the user is a valid amount. If not, prompt the user again. *Check whether the input from the user is a valid amount. If not, prompt the user again. *If the desired expense is more than what is on the card, you prompt the user before charging the expense to the card. *If the desired expense is more than what is on the card, you prompt the user before charging the expense to the card. Line 11: Line 11: ==Solution== ==Solution== + /* + Test Case 1: + Input: 8.50 (input less than initial balance) + Output: balance is 1.50 + Actual: balance is 1.50 + + Test Case 2: + Input: 15.00 (input greater than initial balance), then say Yes to prompt to charge card + Output: reprompt, balance is 0, owes 5.00 + Actual: reprompt, balance is 0, owes 5.00 + + Test Case 3: + Input: 0 (border case) + Output: balance is 10 + Actual: balance is 10 + + Test Case 4: + Input: -1 (negative example) + Output: reprompt + Actual: reprompt + */ + #include <​iostream>​ #include <​iostream>​ #include <​iomanip>​ #include <​iomanip>​