Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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: image text in transcribed

Transcation 2: image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Shouhong Wang, Hai Wang

1st Edition

1612330150, 978-1612330150

More Books

Students also viewed these Databases questions

Question

1. How will you, as city manager, handle these requests?

Answered: 1 week ago

Question

1. Identify the sources for this conflict.

Answered: 1 week ago