This is just the outline. I have to write a program to calculate sales totals fo
ID: 669059 • Letter: T
Question
This is just the outline. I have to write a program to calculate sales totals for a store. Program will have to repeat the process until the last product has been entered, -1 to quit. After each sale program must ask if you want to do another sale, 1 continue, 0 end program. At the beginning cash drawer has 500$ in it. At the end of the program must display how much money is in drawer Input: program must take ProductID Number (int), and Quantity for each item purchased (int) Use following dataset to determine price and taxability for each item. ID, Price, Quantity, Taxable : 101 , $65.00,2, yes 102 , $12.50, 1, no 103 , $24.50 , 5, no 104 $38.75, 4 , yes 105 , $17.80, 6, yes 106 , 16.50, 2, no 107, 42.85, 8, yes 108 32.99 2 yes 109 28.75 1 yes 110 51.55 1 yes Second Sale: 102 12.50 1 no 103 24.50 1 no 106 16.50 1 no 107 42.75 1 yes 108 32.99 1 yes 109 28.75 1 yes 3rd sale 106 16.50 4 no 107 42.85 3 yes 108 32.99 1 yes 109 28.75 5 yes 110 51.55 2 no Assume SalesTax is 7.5%. Here's the outline, ANY HELP IS APPRECIATED. // Retail_Assistant.cpp // Retail Sales Assistant Program // Programmer: // Date: // Description: This program calculates sales tax for a series of products. #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; // Loop for repeat sales // Enter the first Product ID for the first sale (-1 to exit) // Main loop for each sale // Switch statement to determine the price, and calculate sales tax, if any, for the item. // Get next Product ID // Print properly formatted output for each sale // Another sale? // Display how much is in the cash drawer at the end }Explanation / Answer
Your required code in C++ is below:
/*ID, Price, Quantity, Taxable :
101 , $65.00,2, yes
102 , $12.50, 1, no
103 , $24.50 , 5, no
104 $38.75, 4 , yes
105 , $17.80, 6, yes
106 , 16.50, 2, no
107, 42.85, 8, yes
108 32.99 2 yes
109 28.75 1 yes
110 51.55 1 yes
Second Sale:
102 12.50 1 no
103 24.50 1 no
106 16.50 1 no
107 42.75 1 yes
108 32.99 1 yes
109 28.75 1 yes
3rd sale
106 16.50 4 no
107 42.85 3 yes
108 32.99 1 yes
109 28.75 5 yes
110 51.55 2 no
Assume SalesTax is 7.5%. */
// Retail_Assistant.cpp
// Retail Sales Assistant Program
// Programmer:
// Date:
// Description: This program calculates sales tax for a series of products.
#include <iostream>
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;
int i = 1;
// Loop for repeat sales.Assume we have atleast one sale.
while(anotherSale != 0)
{
// Enter the first Product ID for the first sale (-1 to exit)
subtotal = 0.0;
salesTax = 0.0;
cout<<"Enter the first Product ID: ";
cin>>productID;
// Main loop for each sale
while(productID != -1)
{
cout<<"Enter the quantity sold of type productID "<<productID<<": ";
cin>>quantity;
// Switch statement to determine the price, and calculate sales tax, if any, for the item.
switch(productID)
{
case 101:
price = 65.00;
salesTax += price * 0.075 * quantity;
break;
case 102:
price = 12.50;
break;
case 103:
price = 24.50;
break;
case 104:
price = 38.75;
salesTax += price * 0.075 * quantity;
break;
case 105:
price = 17.80;
salesTax += price * 0.075 * quantity;
break;
case 106:
price = 16.50;
break;
case 107:
price = 42.85;
salesTax += price * 0.075 * quantity;
break;
case 108:
price = 32.99;
salesTax += price * 0.075 * quantity;
break;
case 109:
price = 28.75;
salesTax += price * 0.075 * quantity;
break;
case 110:
price = 51.55;
salesTax += price * 0.075 * quantity;
break;
default:
cout<<"Invalid ProductID."<<endl;
}
subtotal += salesTax + price * quantity;
// Get next Product ID
cout<<"Enter the next Product ID: ";
cin>>productID;
}
// Print properly formatted output for each sale
cout<<"The total of this sale is: "<<subtotal<<"."<<endl;
totalSale += subtotal;
// Another sale?
cout<<"Do you have another sale(1. Continue, 0. End): ";
cin>>anotherSale;
}
cashDrawer += totalSale;
// Display how much is in the cash drawer at the end
cout<<"The balance in the cash drawer is: "<<cashDrawer<<"."<<endl;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.