Create a structure named Purchase. Each Purchase contains an invoice number, amount of sale, and amount of sales tax. Create a main() function that declares a Purchase variable and prompts the user for purchase details. When you prompt for an invoice number, do not let the user proceed until a number between 1000 and 8000 has been entered. When you prompt for a sales amount, do not proceed until the user has entered non-negative value. Compute the sales tax as 5 percent of the purchase price. After a valid Purchase variable has been created, display the variable’s invoice number, sale amount and sales tax.
1
Expert's answer
2011-10-18T08:18:06-0400
#include "iostream"
using namespace std;
struct Purchase { public: int InvoiceNumber; int AmountSale; int Price; };
int main() { Purchase byer; cout<<"Enter the Invoice Number plz "<<endl; cin>>byer.InvoiceNumber; if (byer.InvoiceNumber>=800 && byer.InvoiceNumber<=1000) { & & cout<<"Enter the Amount of sale plz"<<endl; & & cin>>byer.AmountSale; & if(byer.AmountSale>0) & { & cout<<"Enter the price plz"<<endl; cin>>byer.Price; int sum; double tax; sum = byer.AmountSale*byer.Price; tax = tax*0.05; cout<<"The Invoice Number: "<<byer.InvoiceNumber<<endl; cout<<"Total sun of the Purchase: "<<sum<<endl; cout<<"Tax of the Purchase: "<<tax<<endl; } else { cout<<"You enter the incorrect number"<<endl; } & } else { & cout<<"You enter the incorrect number"<<endl; & } system("pause"); return 0; }
Comments
Leave a comment