Question
Using C++ ... Accept a number of quarters in a piggy bank as input from users. Continuously prompt users for the number of quarters until
Using C++ ...
Accept a number of quarters in a piggy bank as input from users. Continuously prompt users for the number of quarters until they enter a value greater than zero.
Use a function to validate that the input was greater than zero. This function should accept an integer for the number of coins as its only parameter and return a boolean value. Display an error message if the number of coins is less than or equal to zero.
Use a function to calculate the total cash in the piggy bank. This function should accept an integer for the number of coins and a float for the value of each coin as its parameters. This function should return the result of the calculation of the total cash.
Use a function to calculate the result of investing the total cash using a simple annual interest formula. The annual interest rate is 4.5% and the investment term is 5 years. This function should accept a double for the initial investment, a double for the interest rate, and an integer for the length of the investment term as its parameters. This function will return the result of the balance plus the interest calculation.
================================================================================================================================
Clear the screen and display the number of coins, total cash, and the value of the investment.
Use a function to output a comment on the value of the cash in the piggy bank (see cases below). Accept a double for the amount of cash, and return a string message.
Total cash values less than or equal to $50 output a comment of Youre broke!
Total cash values less than or equal to $100 output a comment of Youve got some cash!
All other total cash values output a comment of Youre rich!
Continuously prompt the user, asking whether or not they would like to enter another investment amount. Allowable responses are y or n. Use a function that accepts a char as its only parameter, and returns a boolean value. Any time the user enters a value that is not y or n display an error message from this function and return a value of false, otherwise return true. If the user enters y, clear the screen and restart the application from the beginning. If the user enters n, clear the screen and notify the user that the application is ending, then prompt the user to press any key and end the application.
================================================================================================================================
OUTPUT:
Enter the total number of quarters: -6 Please enter only positive numbers. Enter the total number of quarters: 45 Number of quarters in Piggy Bank: 45 Total cash in Piggy Bank $11.25 alue of investment: $13.78 ou' re broke lould you like to enter another amount (y>? d 45 Number of quarters in Piggy Bank: 45 Total cash in Piggy Bank: $11.25 Ualue of investment: $13.78 igg11.25: You' re broke! Would you like to enter another amount y)? d Please enter either 'y' or 'n' Would you like to enter another amount (y)? y 300 Number of gquarters in PiggyBank: 300 Total cash in Piggy Bank: $75.00 Ualue of investment: $91.88 (Unrtergy. Bank:g5%a00: You've got some cash! 2 Number of quarters in Piggy Bank:450 Total cash in Piggy Bank: $112.50 alue of investment: $137.81 nding application. You' re rich! ress any key to continue . - Would you like to enter another amount (y)? nStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started