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.
Expert's answer
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

struct Purchase
int invoiceNum;
float saleAmount;
float tax;

int main ()
Purchase purchase;
& cout<< "Enter invoice number (between 1000 and 8000)"<< endl<< "> ";
& cin >> purchase.invoiceNum;
while(purchase.invoiceNum < 1000 || purchase.invoiceNum > 8000);
& cout<< "Enter sale amount (non-negative value)"<< endl<< "> ";
& cin >> purchase.saleAmount;
while (purchase.saleAmount < 0); = 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: "<<<< 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!


No comments. Be the first!

Leave a comment

New on Blog