/* ACTION 5-1 (ACT05_01.cpp) OUTPUT: A MONTHLY REPORT OF THE ITEM NAME, BEGINNING QUANTITY, UNITS SOLD THIS MONTH, ENDING QUANTITY, AND PERCENT OF QUANTITY SOLD INPUT: MONTH OF REPORT, ITEM NAME, BEGIN QTY. UNITS SOLD THIS MONTH PROCESSING: THE PROGRAM MUST CALCULATE TWO THINGS: ENDING QUANTITY AND THE PERCENT SOLD */ //PREPROCESSOR DIRECTIVES #include //FOR cin AND cout #include //FOR string CLASS using namespace std; //REQUIRED WHEN INCLUDING iostream //MAIN FUNCTION int main() { //DEFINE AND INITIALIZE MONTH OBJECT string month = ""; //MONTH OF REPORT //DEFINE AND INITIALIZE ITEM 1 OBJECTS AND VARIABLES string item1 = " "; //SALES ITEM NAME double beginQty1 = 10.0; //BEGINNING QUANTITY double unitsSold1 = 5.0; //NUMBER OF UNITS SOLD double endQty1 = 0; //ENDING QUANTITY double percentSold1 = 0.0; //PERCENT OF SALES //DEFINE AND INITIALIZE ITEM 2 OBJECTS AND VARIABLES string item2 = " "; //SALES ITEM NAME double beginQty2 = 0.0; //BEGINNING QUANTITY double unitsSold2 = 0.0; //NUMBER OF UNITS SOLD double endQty2 = 0; //ENDING QUANTITY double percentSold2 = 0.0; //PERCENT OF SALES //DEFINE AND INITIALIZE ITEM 3 OBJECTS AND VARIABLES string item3 = " "; //SALES ITEM NAME double beginQty3 = 0.0; //BEGINNING QUANTITY double unitsSold3 = 0.0; //NUMBER OF UNITS SOLD double endQty3 = 0; //ENDING QUANTITY double percentSold3 = 0.0; //PERCENT OF SALES //DEFINE AND INITIALIZE ITEM 4 OBJECTS AND VARIABLES string item4 = " "; //SALES ITEM NAME double beginQty4 = 0.0; //BEGINNING QUANTITY double unitsSold4 = 0.0; //NUMBER OF UNITS SOLD double endQty4 = 0; //ENDING QUANTITY double percentSold4 = 0.0; //PERCENT OF SALES //DISPLAY PROGRAM DESCRIPTION MESSAGE cout << "\n\nDear Sporting Goods Manager\n" << "You will be asked to enter four sales items, one at\n" << "a time. With each item you will be asked to enter\n" << "the item name, the beginning quantity, and the quantity\n" << "sold this month. The computer will then print a monthly\n" << "inventory report for the sales items." << endl; //SET MONTH FROM USER ENTRY cout << "\nPlease enter the month in of this report: "; cin >> month; //SET ITEM 1 DATA FROM USER ENTRY cout << "\nPlease enter the item name: "; cin >> ws; getline(cin,item1); cout << "Please enter the beginning quantity of " << item1 << ": "; cin >> beginQty1; cout << "Please enter the quantity of " << item1 << " sold in " << month << ": "; cin >> unitsSold1; //CALCULATE ENDING QUANTITY AND PERCENT SOLD FOR ITEM 1 endQty1 = beginQty1 - unitsSold1; percentSold1 = unitsSold1 / beginQty1 * 100; //SET ITEM 2 DATA FROM USER ENTRY cout << "\nPlease enter the item name: "; cin >> ws; getline(cin,item2); cout << "Please enter the beginning quantity of " << item2 << ": "; cin >> beginQty2; cout << "Please enter the quantity of " << item2 << " sold in " << month << ": "; cin >> unitsSold2; //CALCULATE ENDING QUANTITY AND PERCENT SOLD FOR ITEM 2 endQty2 = beginQty2 - unitsSold2; percentSold2 = unitsSold2 / beginQty2 * 100; //SET ITEM 3 DATA FROM USER ENTRY cout << "\nPlease enter the item name: "; cin >> ws; getline(cin,item3); cout << "Please enter the beginning quantity of " << item3 << ": "; cin >> beginQty3; cout << "Please enter the quantity of " << item3 << " sold in " << month << ": "; cin >> unitsSold3; //CALCULATE ENDING QUANTITY AND PERCENT SOLD FOR ITEM 1 endQty3 = beginQty3 - unitsSold3; percentSold3 = unitsSold3 / beginQty3 * 100; //SET ITEM 4 DATA FROM USER ENTRY cout << "\nPlease enter the item name: "; cin >> ws; getline(cin,item4); cout << "Please enter the beginning quantity of " << item4 << ": "; cin >> beginQty4; cout << "Please enter the quantity of " << item4 << " sold in " << month << ": "; cin >> unitsSold4; //CALCULATE ENDING QUANTITY AND PERCENT SOLD FOR ITEM 1 endQty4 = beginQty1 - unitsSold1; percentSold4 = unitsSold1 / beginQty1 * 100; //DISPLAY REPORT HEADER INFORMATION cout << "\n\nMONTH: " << month << endl; cout << "\n\n\nITEM\tBEGIN QTY\tUNITS SOLD\tENDING QTY" << "\t% SOLD" << endl; cout << "----\t---------\t----------\t----------\t------" << endl; //DISPLAY ITEM REPORT cout.setf(ios::fixed); cout.precision(2); cout << item1 << "\t" << beginQty1 << "\t\t" << unitsSold1 << "\t\t" << endQty1 << "\t\t" << percentSold1 << endl; cout << item2 << "\t" << beginQty2 << "\t\t" << unitsSold2 << "\t\t" << endQty2 << "\t\t" << percentSold2 << endl; cout << item3 << "\t" << beginQty3 << "\t\t" << unitsSold3 << "\t\t" << endQty3 << "\t\t" << percentSold3 << endl; cout << item4 << "\t" << beginQty4 << "\t\t" << unitsSold4 << "\t\t" << endQty4 << "\t\t" << percentSold4 << endl; //RETURN return 0; } //END main()