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

Write a c++ program to solve the following problem: You should provide the follo

ID: 3624238 • Letter: W

Question

Write a c++ program to solve the following problem:
You should provide the following with the problem:
1) a Function Hierarchy Chart
2) a User Documentation – purpose, error checks, sample input and output, variable list
3) a source program with comments
4) 3 sample runs testing:
• a) valid data
• b) errors (ie negative numbers)
• c) no data (ie. no entries)

Write a program to simulate a cash register. Your program should have the following functionality:
A. Write a function that continuously asks for amounts of items purchased, stopping when the amount is <= 0.0 and returns the total amount due.
void Purchase (float& total);
You can use a local variable for the amount. Be sure to set total to 0.0 before starting. (You should add HST to the total before returning its value)

B. Write a function that given the amount owing, displays the amount owing, asks for an amount tendered, and returns the change.
float Change( float total);

C. Write a function that gives the change in the correct denominations. You will not use denominations over $100. (Eg. Hundreds, Fifties, Twenties, Tens, Fives, Toonies, Loons, Quarters, Dimes, Nickels, Pennies). For full marks only write out the denominations that are not 0. Should display the change in float and then the corresponding denominations.
e.g. change of $26.77 should output
1 Twenties, 1 Five, 1 Loons, 3 Quarters, 2 Pennies

void ReportChange(float change);

D. Call the above functions until there are no more customers.


Explanation / Answer

please rate - thanks

#include <iostream>
#include <iomanip>
using namespace std;
void Purchase (float& total);
float Change( float total);
void ReportChange(float change);
int main()
{float total,change;
char more;
cout<<setprecision(2)<<fixed<<showpoint;
do
{total=0;
Purchase(total);
change=Change(total);
ReportChange(change);
cout<<" 1more customers (Y/N): ";
cin>>more;
}while(more=='y'||more=='Y');

return 0;
}
void Purchase (float& total)
{float HST=.13,amt;
int i=1,tot;
cout<<"Enter purchase amount for item "<<i<<" (<=0 to exit): ";
cin>>amt;
while(amt>0)
   {total+=amt;
    i++;
    cout<<"Enter purchase amount for item "<<i<<"(<=0 to exit): ";
    cin>>amt;
    }
total=total+total*HST;
total+=.005;          //round to nearest penny
total*=100;
tot=(int)total;
total=tot/100.;
}
float Change( float total)
{float amt,tot=0,still;
if(total==0)
     return tot;
cout<<"you owe $"<<total<<endl;
do
{
cout<<"How much are you paying? ";
cin>>amt;
tot+=amt;
if(tot<total)
    {still=total-tot;
     cout<<"Sorry, you still owe $"<<still<<endl;
     }
}while(tot<total);

return tot-total;
}
void ReportChange(float change)
{int c,n;
     if(change==0)
         cout<<"We are even ";
     else
        {cout<<"your change is $"<<change<<endl;
         c=(int)(change*100);
         n=c/10000;
         if(n>0)
             cout<<n<<" Hundreds, ";
          c%=10000;
          n=c/5000;
          if(n>0)
             cout<<n<<" Fifties, ";
          c%=5000;
          n=c/2000;
          if(n>0)
              cout<<n<<" Twenties, ";
          c%=2000;
          n=c/1000;
          if(n>0)
               cout<<n<<" Tens, ";
           c%=1000;
           n=c/500;
           if(n>0)
                cout<<n<<" Fives, ";
            c%=500;
            n=c/200;
            if(n>0)
                 cout<<n<<" Toonies, ";
             c%=200;
             n=c/100;
             if(n>0)
                  cout<<n<<" Loonies, ";
             c%=100;
             n=c/25;
             if(n>0)
                  cout<<n<<" Quarters, ";
             c%=25;
             n=c/10;
             if(n>0)
                  cout<<n<<" Dimes, ";
              c%=10;
              n=c/5;
              if(n>0)
                   cout<<n<<" Nickels, ";
              c%=5;
              if(c>0)
                   cout<<c<<" Pennies ";
               }
}

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