Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I am trying to do this C++ project. So far I have the first portion of the hierarchy but I am having difficulty on

Hello, I am trying to do this C++ project. So far I have the first portion of the hierarchy but I am having difficulty on the second portion of the hierarchy (firing the poor performer salesman and distributing the customers). Help please the code will be below. Thank you!!!

Objective: The main objective of this assignment is checking the students ability to work with ADTs. In this week's assignment, you will be writing the interface of an ADT in order to conform to the requirements of a larger application. Description: Multi-Level-Marketing is a quickly growing industry in the United States. Many men and women are deciding to work from home, selling various goods to their friends and family due to the convenience and possible salary that can be made. Multi-Level-Marketing consists of a hierarchy of workers and customers and is sometimes referred to as a pyramid scheme. At the bottom of the chain is the customer who purchases a good or service from a salesman. Above a salesman, there is always a regional salesman/manager who is supplying and managing these bottom level salesmen. Suppose a company that employs a multi-level-marketing strategy is not doing very well and needs to make cuts. After examining the budget, upper level management has realized that some poorly performing salesmen actually cost more to insure than they make for the company. Therefore, upper level management has decided that the lowest performing salesman of each regional manager should be fired. Any fired salesmens customers should be distributed to the rest of the salesmen as evenly as possible. Unfortunately, this company does not have a very robust filing system and needs a way to automatically calculate who needs to be fired. They ask you to create an automated system that given a text file of the workers and customers information can automatically detect who should be fired and which salesmen will get left over customers. Given the customer and worker information, you are required to print the hierarchy of this region to the screen before and after the firing. Input File: The input file you are given first lists the information of the regional manager consisting of an ID, a name, and a salary. Your program is required to store this information and provide ways to manipulate this information properly. For this assignment, a manager always has 5 salesmen working for them. The next item to extract from the file is a salesmens information. A salesman has an ID, a name, a gender, and an indication of how many customers they have. After a salesmans information comes the information of all the customers that this worker is selling to. For example, if a salesman sells to two customers, the next two entries will be customer information (here an entry begins and ends with a blank line). A customers only information is a name and a total amount of money they have spent. This same pattern is repeated until all 5 salesmen and their customers are printed. Help: The best start, for this assignment, is identifying (naming) the ADTs this is the most critical step. Good decisions (choices) naming the ADTs facilitate the implementation. Please spend enough time thinking about the possible names of the ADTs, which you can use to implement this assignment. The names of these ADTs should be very obvious from the description above. Example output: The way that you print out the hierarchy of the region is left up to you. If the information is easy to read and understand, you will get full credit. Be sure to print out the region hierarchy before and after a salesman is fired. Here is an example:

Input file:

1039547 Jabob Smith 120000

1033547 Gwenn Mccloy Male 2

Hildegard Rutz 39.46

Lydia Feng 58.21

1478021 Hildegard Rutz Female 1

Noreen Encarnacion 1.23

1098576 Deirdre Stayer Female 4

Wade Peffer 5.24

Ronda Ord 89.99

Lacresha Lawrence 22.54

Zackary Schiro 19.95

122354 Deirdre Stayer Female 1

Marcus Curl 2.22

187213 Tyesha Overton Male 2

Celine Mccutchan 52.29

Debra Widger 2.55

#include #include #include #include using namespace std; #define MAX 20 //Create Customer class class Customer { private: string name; double money; public: void setName(string n) { name = n; } void setMoney(double m) { money = m; } string getName() { return name; } double getMoney() { return money; } }; //Create Salesman class class Salesman { private: string id; string name; string gender; int numCustomers; double sales=0; public: Customer c[MAX]; void addToSales(double s) { sales += s; //cout << "sale= " << getSales() << endl; } void setID(string i) { id = i; } void setName(string n) { name = n; } void setGender(string g) { gender = g; } void setNumCutomers(int n) { numCustomers = n; } string getID() { return id; } string getName() { return name; } string getGender() { return gender; } int getNumCutomers() { return numCustomers; } double getSales() { return sales; } }; //Create Manager class class Manager { private: string id; string name; double salary; public: Salesman s[MAX]; void setID(string i) { id = i; } void setName(string n) { name = n; } void setSalary(double s) { salary=s; } string getID() { return id; } string getName() { return name; } double getSalary() { return salary; } }; int main() { //Create array of manager objects Manager m[MAX]; //Also delcare necessary varaibles ifstream readFile;

string tempStr; int tempInt; double tempDbl;

int mCount = 0; int sCount = 0; int cCount = 0;

//Open input file readFile.open("input.txt"); //Read data from file while (!readFile.eof()) { //Read mananger's id getline(readFile, tempStr); while (tempStr == "") { getline(readFile, tempStr); } //Set manager's id m[mCount].setID(tempStr); //Read mananger's name getline(readFile, tempStr); //Set manager's name m[mCount].setName(tempStr); //Read manager's salary readFile >> tempDbl; //Set manger's salary m[mCount].setSalary(tempDbl); sCount = 0; //Read five sales persons data while (sCount < 5) { //Read salesperson's id getline(readFile, tempStr); while (tempStr == "") { getline(readFile, tempStr); } //Set salesperson's id m[mCount].s[sCount].setID(tempStr); //Read salesperson's name getline(readFile, tempStr); //Set salesperson's name m[mCount].s[sCount].setName(tempStr); //Read salesperson's gender readFile >> tempStr; //Set salesperson's gender m[mCount].s[sCount].setGender(tempStr); //Read number of custmers readFile >> tempInt; //Set number of custmers m[mCount].s[sCount].setNumCutomers(tempInt); cCount = 0; //Read each customer data while (cCount < m[mCount].s[sCount].getNumCutomers()) { //Read customer's name getline(readFile, tempStr); while (tempStr == "") getline(readFile, tempStr); //Set customer's name

m[mCount].s[sCount].c[cCount].setName(tempStr); //Read money spent by customer readFile >> tempDbl; //Set money spent by customer

m[mCount].s[sCount].c[cCount].setMoney(tempDbl); //Add money spent by customer to salesperson's sale m[mCount].s[sCount].addToSales(tempDbl); cCount++; } sCount++; } mCount++; } //Now display the Manager, salespersons and customers data for (int i = 0; i < mCount; i++) { //Print manager's details cout << "Manager:\t" << m[i].getName() <<"\t"<< m[i].getSalary()<

//Print each salesperson's details and thier customers details for (int j = 0; j < 5; j++) { cout << "\tSalesPerson:\t " << m[i].s[j].getName()<<"\t\t"<

//Print customer details for (int k = 0; k < m[i].s[j].getNumCutomers(); k++) { cout << "\t\tCustomer:\t " << m[i].s[j].c[k].getName() << "\t\t" << m[i].s[j].c[k].getMoney() << endl; } } } cout << "=======================================================================" << endl;

return 0; }

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

Step: 3

blur-text-image

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 Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

Write a program to check an input year is leap or not.

Answered: 1 week ago

Question

Write short notes on departmentation.

Answered: 1 week ago

Question

What are the factors affecting organisation structure?

Answered: 1 week ago

Question

What are the features of Management?

Answered: 1 week ago

Question

Briefly explain the advantages of 'Management by Objectives'

Answered: 1 week ago