Question
Develop a method named deductCurrency() which takes four parameters: The first parameter is a double value of a currency, the second parameter is a string
Develop a method named deductCurrency() which takes four parameters: The first parameter is a double value of a currency, the second parameter is a string singular label of the currency, the third parameter is a string plural label of the currency and the fourth parameter is a call-by-reference double of the amountLeft. Move the code from the main()function which calculates one of the currencies to the deductCurrency() function and modify it to use the parameters to correctly handle all currencies. Then remove all the currency calculations from the main() function and call the deductCurrency() function for each currency similar to the following.
deductCurrency(penny, "penny", "pennies", amountLeft);
- Where possible, use "compound operators".
- Use if statements, ternary operators, whatever so that the program doesn't display any output for zero bills & coins and doesn't display the 's' for single bills & coins as in the sample output shown below.
-
Enter amount you want change for: 123.45 Change for $123.45 2 $50s 1 $20 3 $1s 1 quarter 2 dimes
Step 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