Question

Goal: Design and build a simple cash register program in C++ using the programming constructs included...

Goal: Design and build a simple cash register program in C++ using the programming constructs included (simple expressions, a loop, and if statements).

Problem: A company needs a cash register program to work on their new computer system. The program should first ask whether the payment is in cash and credit card. If it is a credit card transaction, you must get the card pin. The program will then read in a number of prices to read, finally it must read in that many prices and compute the total. A discount is computed from the total at these rates:

$100 3% discount $1000 5% Discount $10,000 11% Discount

The amount of the discount is displayed if it is applicable. Taxes should be computed on the discounted total price at a 6% rate and the information should be displayed on the screen.

Homework Answers

Answer #1

Note:

please check the program ,if you need any changes I will do it.

___________________

#include <iostream>
#include <cmath>
using namespace std;

//Function declaration
void tax(double tot,double discount);
int main ()
{
   //Declaring variables
char ch;
int num,pin;
double tot=0,price,discount;
  
//Getting the input entered by the user
cout<<"Card (or) Cash ('c' for Credit Card 's' for cash) :";
cin>>ch;
  
//Based on the user input the corresponding case will get executed
switch(ch)
{
   case 'c':
   case 'C':
       {
           //getting the pin number
           cout<<"Enter the pin no :";
   cin>>pin;
  
   //Getting the prices entered by the user and calculating the total
   cout<<"No of prices to read :";
   cin>>num;
  
   for(int i=0;i<num;i++)
   {
       cout<<"Enter price "<<i+1<<":";
       cin>>price;
      
       tot+=price;
   }
break;
       }
       case 's':
           case 'S':
               {  
   //Getting the prices entered by the user and calculating the total          
   cout<<"No of prices to read :";
   cin>>num;
  
   for(int i=0;i<num;i++)
   {
       cout<<"Enter price "<<i+1<<":";
       cin>>price;
      
       tot+=price;
   }
   break;
   }
   default:{
      
       break;
   }
  
}

//based on the total amount apply discount and calculate the tax
if(tot>=100 && tot<1000)
{
   //Calculating the discount amount
   discount=0.03*tot;
   cout<<"Discount : $"<<discount<<endl;
  
   //Calling the function which calculates the tax
   tax(tot,discount);
  
}
else if(tot>=1000 && tot<10000)

    //Calculating the discount amount{
    discount=0.05*tot;
    cout<<"Discount : $"<<discount<<endl;
   
        //Calling the function which calculates the tax
tax(tot,discount);
}
else if(tot>=10000)
{
        //Calculating the discount amount
    discount=0.11*tot;
    cout<<"Discount : $"<<discount<<endl;

        //Calling the function which calculates the tax
tax(tot,discount);
}



return 0;

}

//Function implementation which calculates the tax
void tax(double tot,double discount)
{
   double tax=0.06*(tot-discount);
   cout<<"Amount of tax is : $"<<tax<<endl;
}

____________________

output:

____________Thank You

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT