Question: How to get C++ program to do correct output? PROGRAM : #include #include using namespace std; int main() { double cashDrawer = 500.00; int productID

How to get C++ program to do correct output?

PROGRAM :

#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) { subtotal=0;

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

cout > productID; if(productID!=-1) { 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; if(productID!=-1) { 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

}

Transaction 1: How to get C++ program to do correct output? PROGRAM : #include

Transcation 2: #include using namespace std; int main() { double cashDrawer = 500.00; int

Each transaction is supposed to have its OWN total not added. The program correctly outputs the total of each sale BUT outputs incorrect total in cash drawer. output below, please help.

OUTPUT:

Enter the first product ID (-1 to exit): 101 Enter quantity of item purchased: 2 Enter the next product ID: 102 Enter quantity of product: 1 Enter the next product ID: -1 The total sale for this transaction is: 142.5 if there is another sale press 1 to continue OR 0 to end: 1 Enter the first product ID (-1 to exit): 101 Enter quantity of item purchased: 2 Enter the next product ID: -1 The total sale for this transaction is: 130 if there is another sale press 1 to continue OR 0 to end: 0 The balance in the cash drawer is $782.25

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!