89 080
Assignments Done
97.9%
Successfully Done
In July 2020

# Answer to Question #15173 in C++ for GatorGirl

Question #15173
My assignment is to write a program to calculate sales total. My program will not know how many products each customer will buy, so it will have to repeat the process until a last product has been entered (I am suppose to use -1 for product ID to end each sale). After each sale my program is suppose to ask if they want to do another sale (y-continue, N-end program). The cashDrawer will have \$500.00 in it. I must display how much money is in the drawer after handling all sales transactions.Below is my code and it does not work. Please help. This is due tonight at 9pm.

#include &lt;iostream&gt;
#include &lt;iomanip&gt;
#include &lt;cmath&gt;

using namespace std;

//function main begins program execution

int main()
{
double cashDrawer = 500.00;
int productID = 0;
double price = 0.0;
double subtotal = 0.0;
double salesTax = 0.0;
double total = 0.0;
char anotherSale = &#039;y&#039;;
int quantity = 0;
double taxRate = 0;

// Loop for repeat sales

while (anotherSale == &#039;y&#039;)
{

double price = 0.0;
double subtotal = 0.0;
double salesTax = 0.0;
double total = 0.0;
int quantity = 0;
double taxRate = 0;;

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

cout &lt;&lt; &quot;Enter the product ID or -1 to quit: &quot; &lt;&lt; endl;
cin &gt;&gt; productID;

cout &lt;&lt; &quot;Enter quantity: &quot; &lt;&lt; endl;
cin &gt;&gt; quantity;

// Main loop for each sale

while (productID != -1)
{

// Switch statement to determine the price, and calculate sales tax, if any, for the item.

switch (productID)
{
case 101:
price = 65.00;
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;

default:
cout &lt;&lt; &quot;You have entered an incorrect product ID.&quot; &lt;&lt; endl;
}
subtotal += (quantity * price) + (quantity * price * taxRate);
total = subtotal + total;
}

subtotal += (quantity * price) + (quantity * price * taxRate);
total = subtotal + total;

}
// Get next Product ID

cout &lt;&lt; &quot;Enter the next product ID or -1 to quit: &quot; &lt;&lt; endl; //prompt user for input
cin &gt;&gt; productID;

cout &lt;&lt; &quot;Enter quantity: &quot; &lt;&lt; endl;
cin &gt;&gt; quantity;

//}
// Print properly formatted output for each sale

cout &lt;&lt; &quot;The subtotal is: &quot; &lt;&lt; subtotal &lt;&lt;endl;
cout &lt;&lt; &quot;The total is &quot; &lt;&lt; total &lt;&lt; endl;
cout &lt;&lt; &quot;Would you like to do another sale? (y-Continue, n-End Program)&quot; &lt;&lt; endl;
cin &gt;&gt; anotherSale;

// Display how much is in the cash drawer at the end

cashDrawer = cashDrawer + total;
cout &lt;&lt; &quot;The money in the drawer after handling all transactions is &quot; &lt;&lt; cashDrawer &lt;&lt; endl;

system (&quot;pause&quot;);

return 0;
}
1
2012-09-21T07:25:13-0400
Submit it with all requirements as an assignment to our control panel and we&#039;ll assist you.

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!