Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Make Change program - C++ Write a program to input two float values. The first f

ID: 668314 • Letter: M

Question

Make Change program - C++

Write a program to input two float values. The first float is the cost of some purchase made, or the cost of goods, and the second is the payment value towards the cost. You are to determine the change (if any) to return to the customer. You must also determine if they gave you enough money to cover the cost, if they didn't, print out you are short on funds, so pay more.
The change should be the number of 20 dollar bills to return, then the number of 10's, 5's, and 1's in bills. Then the change for coins, the number of 50 cents, .25 cents (quarters), 10 cents (dimes), 5 cents (nickels), and pennies. DO NOT print out 0 for any of the above values (if they don't get any 20 dollar bills back, don't print "0 20 dollar bills". You just don't print anything.)
Print out the 'cost' and the 'payment' and then the amount of change to return.

Example:

0.81     1.00
Example output:
purchase   pay   change
0.81          1.00    1 dime, 1 nickel, 4 pennies

NOTE: Can't use arrays or classes yet as we haven't covered them.

Explanation / Answer

#include //used for getchar #include //used for cin and cout #include //used to modify text strings setprecision #include //needed for strings #include "....usinessLayer.h" // is numeric using namespace std; //You are to pass the purchase prices to the function by value. Since you //want to return the number of $5, $1, quarters, dimes, nickels, and pennies as well, //you must pass these by reference. bool getchange(double dblPrice,int &F,int &O,int &Q,int &D,int &N,int &P); //$5, $1, quarters, dimes, nickels, and pennies int main() { bool quit = false; //initialize variables here while (quit == false) { // 90378: Computer Programming C++ 90378 // Tater Schuld 500139932 // //1/12/2010 //C++ Programming //Assignment 13 //change // //Write a C++ user defined function change that will calculate the least number of coins //and bills needed to create change for a purchase. // //Note: you may have some rounding problems due to C++s treatment of floating point //values. Deal with this appropriately. really? how? // cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote