Answer to Question #3295 in C++ for sya

Question #3295
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-07-05T07:35:19-0400
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

struct Purchase
{
int invoiceNum;
float saleAmount;
float tax;
};


int main ()
{
Purchase purchase;
do
{
& cout<< "Enter invoice number (between 1000 and 8000)"<< endl<< "> ";
& cin >> purchase.invoiceNum;
}
while(purchase.invoiceNum < 1000 || purchase.invoiceNum > 8000);
do
{
& cout<< "Enter sale amount (non-negative value)"<< endl<< "> ";
& cin >> purchase.saleAmount;
}
while (purchase.saleAmount < 0);

purchase.tax = 0.05F * purchase.saleAmount;

system ("cls");

cout<< "& **PURCHASE DETAILS"<< endl<< endl;
cout<< "Invoice number: "<< purchase.invoiceNum<< endl;
cout<< "Sale amount: "<< purchase.saleAmount<< endl;
cout<< "Sales tax: "<< purchase.tax<< endl;
&
system ("pause");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS