In: Computer Science
Please read the following program requirements carefully:
You are working as an eBay Seller, where your customers are only in New York (n), New Jersey (j) and Pennsylvania (p).
Your C++ program is supposed ask the name of the state where the purchase is made. (n or j or p)
Next your program asks the amount of purchase.
Then, you calculate the Total amount by adding the proper State sales tax calculation to the Purchase Amount by using,
Sales tax in NY : 8.875% Sales tax in NJ : 6.625% Sales tax in PA : 6%
Finally print the Total on the screen for each transaction.
EXITING THE PROGRAM: Program may be exited in either of the following 2 ways: (If you implement only 1 exit methodology , you will have 7 points deduction)
1. User can enter q (for quit) instead of state name
2. User can answer a question: “Do you have another purchase to calculate the Total (y/n) ? “ and if the answer is n (for no)
C++ programming
#include<iostream>
using namespace std;
int main(){
char name,flag;
float amount,total=0;
while(true){
cout<<"Enter name of the
state where the purchase is made. (n or j or p)"<<endl;
cin>>name;
if(name=='q'){
exit(1);
}
cout<<"Enter amount of
purchase"<<endl;
cin>>amount;
if(name=='n'){
total=amount+(amount*0.0875);
}
else if(name=='j'){
total=amount+(amount*0.06625);
}
else if(name=='p'){
total=amount+(amount*0.06);
}
cout<<"Total:
$"<<total<<endl;
cout<<"Do you have another
purchase to calculate the Total (y/n) ?"<<endl;
cin>>flag;
if(flag=='n'){
break;
}
}
}
Expected output: