For this assignment, write a program that will process sales information for a c
ID: 3542018 • Letter: F
Question
For this assignment, write a program that will process sales information for a company. The company sells many products, but they are categorized into 3 product types: gizmos, doohickeys, and thingamajigs.
A product number will be used to signify the product type as follows:
The lower and upper bounds for the various ranges of product numbers should be made into symbolic constants and those names should be used in the executable code.
The user should initially be prompted for the product number of the item that was purchased. As long as a product number of -1 has not been entered, the user should then be prompted for 2 more pieces of information: the number of items that were purchased, and the price for one of those items.
The product number should be used to determine which type of product was purchased. For each of the product types, keep track of the total number of items sold and the total cost of all sales of that product. If the product number is invalid, then a counter of the number of invalid sales should be incremented.
After the sale has been processed, the user should be prompted for the product number of the next purchase. And as mentioned above, this processing should continue until the user enters a product number of -1 to indicate that there is no more sales information to be entered.
After the user enters the product number of -1, display the total number of items sold and total cost for each of the products and the total number of invalid sales.
Your program must be fully documented. Line documentation should be used wherever needed, but need not be on every line of code. White space and indentation should be used to make your code easily readable. See the documentation standards on the course webpage.
The values that are used in the Sample Output displayed below can be found here. However, it would be a good idea to test your program with a smaller subset of values.
Explanation / Answer
/***************************************************************
Purpose: process sales information for a company
***************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main(int argc, const char * argv[])
{
//declare Constants
int LOW_GIZ = 0;
int HIGH_GIZ = 999;
int LOW_HOOH = 1000;
int HIGH_HOOH = 2999;
int LOW_MAJIGS = 3000;
int HIGH_MAJIGS = 5999;
//Deleare Variables
int intProNum = 0;
int intQty = 0;
double dblPrice = 0.0;
int intGizCnt = 0;
int intHoohCnt = 0;
int intMajigsCnt = 0;
int intInvalid = 0;
double dblGizSale = 0.0;
double dblHoohSale = 0.0;
double dblMajigsSale = 0.0;
//ask for inout
cout << "Enter the product number of the item sold: ";
cin >> intProNum;
//while the input is valid
while (intProNum != -1)
{
//ask for input
cout << endl;
cout << "Enter the number of items sold: ";
cin >> intQty;
cout << endl;
cout << "Enter the price for one of the items: ";
cin >> dblPrice;
cout << endl << endl;
//
if (intProNum >= LOW_GIZ && intProNum <= HIGH_GIZ)
{
intGizCnt = intGizCnt + 1; //intcrement number of Gizmos
dblGizSale = dblGizSale + dblPrice; //increase sales
}
else if (intProNum >= LOW_HOOH && intProNum <= HIGH_HOOH)
{
intHoohCnt = intHoohCnt + 1; //increment number of doohickeys
dblHoohSale = dblHoohSale + dblPrice; //increase sales
}
else if (intProNum >= LOW_MAJIGS && intProNum <= HIGH_MAJIGS)
{
intMajigsCnt = intMajigsCnt + 1; //increment number of thingamajigs
dblMajigsSale = dblMajigsSale + dblPrice; //increase sales
}
else
{
//increment number of invalids
intInvalid = intInvalid + 1;
}
//more?
cout << "Enter the product number of the item sold: ";
cin >> intProNum;
}//end while
//Display results
cout << "***** Product Sales Summary *****" << endl << endl;
cout << "Gizmo Count: " << intGizCnt << endl;
cout << "Gizmo Sales Total: " << setprecision(2) << fixed << dblGizSale << endl;
cout << endl;
cout << "Doohickey Count: " << intHoohCnt << endl;
cout << "Doohickey Sales Total: " << setprecision(2) << fixed << dblHoohSale << endl;
cout << endl;
cout << "Thingamajig Count: " << intMajigsCnt << endl;
cout << "Thingamajig Sales Total: " << setprecision(2) << fixed << dblMajigsSale << endl;
cout << endl;
cout << "Invalid Sales: " << intInvalid << endl;
cout << endl << endl << endl;
//end main
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.