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

Please help... I need an IPO Chart for the following question. Using C++ Languag

ID: 3572102 • Letter: P

Question

Please help... I need an IPO Chart for the following question. Using C++ Language

You are at my store and I am a stickler for making sure the cash drawer is exactly correct each night. I need a program that takes in two inputs:
1) The total amount of any sale (tax and any discounts already included) 2) The amount of money the customer gave you
The program will then calculate and display the exact amount of change to be given back to the customer. Not so easy; the display will tell you exactly how many of each of the following to give to the customer: Dollars: 20, 10, 5 and 1 Change: quarters, dimes, nickels and pennies
In other words, for the money denominations listed above, your program must calculate and display the number of each denomination (if needed).

The following is an example of the console display

Amount of sale: $35.67
Amount tendered: $40.00
The change is . . . $4.33
4 one dollar bills
1 quarter
1 nickel
3 pennies

Explanation / Answer

//Tested on Linux,Ubuntu

/*****************************IpoChart.cpp***********************/

#include <iostream>
#include <cmath>
using namespace std;
//constant declaration and initilization
int const cents=1;
int const nickel=5*cents;
int const quarter=25*cents;
int main() {
//variable declaration
float amountOfSale,amountTendered;
int totalNoOfNickel,totalNoOfQuarter,totalNoOfPennies,totalNoOfDollar;
float change,fractionPart;

//prompt for user input
std::cout<<"The total amount of any sale"<<std::endl;
std::cin>>amountOfSale;

std::cout<<"The amount of money the customer gave you"<<std::endl;
std::cin>>amountTendered;

cout<<"Amount of sale: $"<<amountOfSale<<std::endl;
cout<<"Amount tendered: $"<<amountTendered<<std::endl;

//calculating changes
change=amountTendered-amountOfSale;
cout<<"The change is . . . $"<<change<<std::endl;

//calculating total number of Dollar
totalNoOfDollar=(int)change;

//calculating fraction part from change
fractionPart=roundf((change-totalNoOfDollar)*100);

cout<<totalNoOfDollar<<" one dollar bills "<<std::endl;

//calculating Total number of Quarter
totalNoOfQuarter=fractionPart/quarter;
//printing Total number of Quarter
cout<<totalNoOfQuarter<<" quarter "<<std::endl;
//calculating Total number of Nickel
totalNoOfNickel=(fractionPart-(totalNoOfQuarter*quarter))/nickel;
//Printing Total number of Nickel
cout<<totalNoOfNickel<<" nickel "<<std::endl;
//calculating Total number of Pennies
totalNoOfPennies=(fractionPart-(totalNoOfQuarter*quarter)-(totalNoOfNickel*nickel));
//printing Total number of pennies
cout<<totalNoOfPennies<<" pennies "<<std::endl;

return 0;
}


/*****************output*******************/

lalchand@lalchand:~/Desktop/chegg$ g++ IpoChart.cpp
lalchand@lalchand:~/Desktop/chegg$ ./a.out
The total amount of any sale
35.67
The amount of money the customer gave you
40
Amount of sale: $35.67
Amount tendered: $40
The change is . . . $4.33
4 one dollar bills
1 quarter
1 nickel
3 pennies

Thanks a lot. If you have any query please feel free to ask.