Question

Need help with this programming please this is the instruction my teacher provided

Write a C++ class called Sales and a main( ) function that uses the class. Also, write documentation of your project. Below is a specification of the class. . INTRODUCTION A company has four salespeople (1 to 4) who sell five different products ( to 5)1. Once a day each salesperson passes in a slip for each different type of product sold. Each slip contains: The salesperson number The product number Date of sale The total dollar value of that product sold that day Thus a salesperson passes in between 0 and 5 slips per day Here is an example of daily sales data: PRODUCT ID AMOUNT 127.57 3123.99 47.77 500.00 268.72 SALESPERSON ID 894.50 2. DATA STRUCTURES First, provide a struct of the sales slip. Second, provide the class whose data members are as follows: A one-dimensional array of slip structures to be used to store sales information for all the sales people for a month. A two dimensional array that wil array where the rows shall represent salesperson and the columns shall represent product. A one-dimensional A one dimensional array of product names. l contain a summary of the data from the one dimensional ional array of names of the four salespersons. 3. PROGRAM LOGIC 3.1 Input A function member of the class to input data into the one-dimensional array from the keyboard.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <algorithm>
using namespace std;

class Sales
{
private:
string salespersons[4] = {"Anderson", "Maxwell ", "Jimmy", "Tom"};
string products[5] = {"Baskets ", "Vacuum cleaner", "Window cleaner", "Jugs", "Cups"};
double slips[3];
double summary[5][3] = { {0,0,0}, {0,0,0}, {0,0,0},{0,0,0},{0,0,0}};
double total = 0;
double grandtotal = 0;
  
public:
//member function to get sales slips
void inputSales(void);
//member function to print sales summary
void computeTotal(int i);
//member function to print sales summary
void outputTable(void);
};

//member function definition, outside of the class
void Sales::inputSales(void){
cout << "\n" ;
cout << "Enter sales person ID: " ;
cin >> slips[1];
cout << "Enter product ID: ";
cin >> slips[2];
cout << "Enter amount: ";
cin >> slips[3];   
}

//member function definition, outside of the class
void Sales::computeTotal(int i){   
summary[i][1] = slips[1];
summary[i][2] = slips[2];
summary[i][3] = slips[3];   
}

//member function definition, outside of the class
void Sales::outputTable(void){
cout << "\n DOODAD THIRD QUARTER 2016 SALES REPORT \n";
cout << "\n";
cout << "SALES PERSON";
cout << "\t PRODUCT";
cout << "\t AMOUNT";
cout << "\t TOTAL";
  
cout << "\n";
cout << "------------";
cout << "\t ------------";
cout << "\t ------------";
cout << "\t ------------";
  
int c1 = summary[0][1]-1;
int c2 = summary[0][2]-1;
cout << "\n" << salespersons[c1];
cout << "\t" << products[c2];
cout << "\t" << summary[0][3];
total = summary[0][3];
grandtotal = summary[0][3];
  
for (int k = 1; k <= 4; k++) {
if (summary[k][1] != summary[k-1][1]){
cout << "\t\t" << total;
cout << "\n";
}

if (summary[k][1] == summary[k-1][1]){
total += summary[k][3];
}else{
total = summary[k][3];
}
grandtotal += summary[k][3];
  
int c1 = summary[k][1]-1;
int c2 = summary[k][2]-1;
cout << "\n" << salespersons[c1];
cout << "\t" << products[c2];
cout << "\t\t" << summary[k][3];
}
cout << "\t\t" << total;
cout << "\n";
cout << "\n GRAND TOTAL OF ALL SALES : " << "\t\t\t\t" << grandtotal;
}

int main()
{
Sales std; //object creation
for (int i = 0; i <= 4; i++){
std.inputSales();
std.computeTotal(i);
}
std.outputTable();

return 0;
}

Add a comment
Know the answer?
Add Answer to:
Need help with this programming please this is the instruction my teacher provided Write a C++...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use a two-dimensional array to solve the following problem. A company has four salespeople (0 to...

    Use a two-dimensional array to solve the following problem. A company has four salespeople (0 to 3) who sell five different products (0 to 4). Once a day, each salesperson passes in a slip for each different type of product sold. Each slip contains the following: a) The salesperson number b) The product number c) The total dollar value of that product sold that day Thus, each salesperson passes in between 0 and 5 sales slips per day. Assume that...

  • Use a two-dimensional array to solve the following problem. A company has four salespeople (1 to...

    Use a two-dimensional array to solve the following problem. A company has four salespeople (1 to 4) who sell five different products (1 to 5). Once a day, each salesperson passes in a slip for each different type of product sold. Each slip contains the following a) The salesperson number b) The product number c) The total dollar value of that product sold that day Thus, each salesperson passes in between 0 and 5 sales slips per day. Assume that...

  • C++ Background information: A company has four salespeople who sell five different products. Once a day,...

    C++ Background information: A company has four salespeople who sell five different products. Once a day, each salesperson passes in a slip for each different type of product sold. First on the line is the salesperson name, second is the product number, and third is the sales volume for this product by this salesperson in dollars. For example, the line Tara 2 200.00 means that salesperson Tara reported sales of volume $200.00 for product number 2. Data: Eric 1 200000.00...

  • ho, then print the message "Next flight leaves in 3 hours." 6.22 Total Sales) Use a...

    ho, then print the message "Next flight leaves in 3 hours." 6.22 Total Sales) Use a two-dimensional array to solve the following problem. A company has four salespeople (I to 4) who sell five diferent products (I to 5). Once a day, each salesperson pases in a slip for each different type of product sold. Each slip contains: a) b) c) The salesperson numbor The product number The total dollar value of that product sold that day Thus, each salesperson...

  • In C++. Write another program in file B2.cpp to calculate and print the total sales of...

    In C++. Write another program in file B2.cpp to calculate and print the total sales of each product by each salesperson. Read the sales slips from the file Salesslips.txt (or for partial points, in case your program Bl.cpp does not work correctly, from an array with the same data, initialized in your main program) and calculate the total sales of each product by each salesperson. Accumulate the total sales of each product by each salesperson in a two- dimensional array...

  • PROGRAMMING LANGUAGE OOP'S WITH C++ Functional Requirements: A jewelry designer friend of mine requires a program...

    PROGRAMMING LANGUAGE OOP'S WITH C++ Functional Requirements: A jewelry designer friend of mine requires a program to hold information about the gemstones he has in his safe. Offer the jewelry designer the following menu that loops until he chooses option 4. 1. Input a gemstone 2. Search for a gemstone by ID number 3. Display all gemstone information with total value 4. Exit ------------------------------------- Gemstone data: ID number (int > 0, must be unique) Gem Name (string, length < 15)...

  • Please!!! need help asap!!!! write a C++program to analyze a small subset of the data that...

    Please!!! need help asap!!!! write a C++program to analyze a small subset of the data that has been collected. See file universities.txt .Use precisely seven parallel arrays: one for name of university, one for state, one for city, one for yearly tuition, one for enrollment, one for average freshman retention, and one for the percent of students who graduate with in six years. Note that the percentage of student accepted is not stored.An output file is opened in main() and...

  • Hello, I need help answering all 8 of these questions for my BIS 422 class. I...

    Hello, I need help answering all 8 of these questions for my BIS 422 class. I need the appropriate MySQL script to use for these questions Provide the SQL for the following data requests. Your SQL should be written as a single script that can be pasted into MySQL and run without edits. Make sure you use the proper notation for your comments (see the practice solution for an example of the format). There will be a 5% deduction for...

  • C# Write a program that takes a list of information and grades of the students of...

    C# Write a program that takes a list of information and grades of the students of a class and perform some processing. Take the following steps to write the program. The program must give the user two options such as a menu. At the beginning of the program must ask the following from the user: Which task you want to do (choose an option between 1-2), 1- Entering new information 2- Searching a student If the user types something rather...

  • I need one file please (C++)(Stock Market) Write a program to help a local stock trading...

    I need one file please (C++)(Stock Market) Write a program to help a local stock trading company automate its systems. The company invests only in the stock market. At the end of each trading day, the company would like to generate and post the listing of its stocks so that investors can see how their holdings performed that day. We assume that the company invests in, say, 10 different stocks. The desired output is to produce two listings, one sorted...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT