Question: How to fix C++ program to output correct data? You have been asked to write a program to calculate sales totals for a general store.

How to fix C++ program to output correct data?

You have been asked to write a program to calculate sales totals for a general store. Your program will not know how many products each customer will buy, so your program will have to repeat the process until the last product has been entered (use -1 for Product ID to end each sale). After each sale your program must ask if you want to do another sale (1 continue, 0 end program). At the beginning of the day, the cash drawer has $500 in it. At the end of the program you must display how much money is in the drawer after handling all your sales transactions.

#include #include using namespace std;

int main() { double cashDrawer = 500.00; int productID = 0; int quantity = 0; double price = 0.0; double subtotal = 0.0; double salesTax = 0.0; double totalSale = 0.0; int anotherSale = 1; double taxrate = 0;

// Loop for repeat sales while (anotherSale == 1) {

// Enter the first Product ID for the first sale (-1 to exit)

cout > productID; cout > quantity;

// Main loop for each sale while (productID != -1) {

// Switch statement to determine the price, and calculate sales tax, switch(productID) { case 101: price = 65.0; taxrate = 0.075; break; case 102: price = 12.50; taxrate = 0.0; break; case 103: price = 24.50; taxrate = 0.0; break; case 104: price = 38.75; taxrate = 0.075; break;

case 105: price = 17.80; taxrate = 0.075; break;

case 106: price = 16.50; taxrate = 0.0; break;

case 107: price = 42.85; taxrate = 0.075; break;

case 108: price = 32.99; taxrate = 0.075; break;

case 109: price = 28.75; taxrate = 0.075; break;

case 110: price = 51.55; taxrate = 0.0; break; }

subtotal += quantity * price; salesTax = (quantity * price) * taxrate;

// Get next Product ID cout > productID; cout > quantity; }

// Print properly formatted output for each sale cout

cashDrawer+= totalSale;

// Another sale? cout>anotherSale; } // Display how much is in the cash drawer at the end cout

}

My program is doing two things incorrectly - When i enter -1 it does not exit sale

and also it does exit when you press 0, but it does not give correct output.

please help to correct these issues.

First transcation :

How to fix C++ program to output correct data? You have been

Product ID 101 102 103 104 105 106 107 108 109 110 Price $65.00 12.50 $24.50 $38.75 $17.80 $16.50 $42.85 $32.99 $28.75 $51.55 Quantity Taxable Yes No No Yes Yes No Yes Yes Yes No

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!