subject

In C++ please. A company has sales reps that sell two different product lines. The sales amounts for each product are recorded. A commission is paid based on the total sales. The commission is determined as follows:

Total sales Commission

less than $4000 5% of sales

$4000 to less than $8000 7% of sales

$8000 or more 10% of sales

Data for sales reps is stored in a file salesdata. txt. Each line of the file is in this format:

Salesrep name#sales1 sales2

Create a struct to represent a SalesRep with

-Name

-Product1 sales

-Product 2 sales

-Total sales

-Commission

Create an array of type SalesRep in main that can hold up to 20 reps.

Your program will prompt for the name of the file and validate that it exists. Read the data from the file and populate the array. You will need to count the actual number of sales reps in the file. Make sure your code tests that the array is not overfilled.

Create and generate two reports to an output file called reports. txt:

Sales report Print the name, total sales, and commission for all reps entered into the system in the format shown below on sample output. Also calculate and print the total sales and commission of all reps.

Diamond Club Print the name and total sales of all reps with $10000 or more in total sales

Run your program with this file

James T. Kirk#8500 2650
Bruce Wayne#4880 3120
Harry Potter#1500 850
Peter Parker#9800 5100
Clark Kent#2750 1250
Lois Lane#8250 5200
Bob Blue#5125 7500
Steve Green#1200 3000
Jill White#1500 2500
Sam Black#5200 2800

For FULL credit you should create functions to:

-Read the file

-Calculate the commission for an individual

-Generate the sales report

-Generate the diamond club report

It is better to have working functionality WITHOUT functions than to run out of time … (you will lose 10% of the grade).

If you cannot use structures correctly, this program can be done by reading the file twice to generate each report. You will lose 10% of the grade for this option.

For full credit:

you MUST include comments that document the problem solving process

your code must be properly indented

your code will have functions

output should be formatted so that numbers align as in sample output

Make sure the answers are correct! I am purposely not showing the answers

SAMPLE RUN

Enter name of file: s. txt
s. txt not found, re-enter: sales. txt
Reading file
X records read

Report generated
Programmed by yournme

(in reports. txt)
Sales Report

Employee Total Sales Commission
Captain Kirk $ .xx $ .xx
Bruce Wayne $ .xx $ .xx
Harry Potter $ .xx $ .xx
Peter Parker $ .xx $ .xx
Clark Kent $ .xx $ .xx

Total $ .xx $ .xx

Diamond Club Qualified

Name Total Sales
rep $ .xx
This is what I have so far
// Jimmy Nguyen
#include
#include
#include
#include
#include
using namespace std;

struct SalesRep{
string name;
double sales1;
double sales2;
};
typedef struct SalesRep salesrep;

void read_file(string filename , salesrep sales[] , int max_sales){
int current_sales = 0;
ifstream file(filename);
if(file. is_open()){
string line;
while(getline(file , line) && current_sales < max_sales){
string word;
vector first_split;
stringstream ss(line);
while(getline(ss, word , '#')){
first_split. push_back(word);
}
string sale;
vector second_split;
stringstream ss1(first_split[1]);
while(getline(ss1 , sale, ' ')){
second_split. push_back(sale);
}
sales[current_sales].name = first_split[0];
sales[current_sales].sales1 = stod(second_split[0]);
sales[current_sales].sales2 = stod(second_split[1]);
current_sales += 1;
}
}
file. close();
}

void display(salesrep sales[] , int max_sales){
double overall_sales = 0;
double overall_comm = 0;
cout<<"Employee\t\tTotal Sales\t\t Commission\n";
for(int i=0;i double total_sales = sales[i].sales1 + sales[i].sales2;
overall_sales += total_sales;
double commission;
overall_comm += commission;
if(total_sales < 4000){
commission = total_sales * 0.05;
}
else if(total_sales < 8000){
commission = total_sales * 0.07;
}
else{
commission = total_sales * 0.1;
}
cout< }
cout<<"\nTotal\t\t\t$"< }

int main(){
string filename = "salesdata. txt";
int max_sales = 20;
salesrep sales[max_sales];
read_file(filename , sales , max_sales);
display(sales , max_sales);
return 0;
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:10, Tatertotzzzz
Write a method that accepts a string object as an argument and returns the number of words it contains. for instance, if the argument is "four score and seven years ago", the method should return the number 6. demonstrate the method in a program that asks the user to input a string and then passes that string into the method, printing out whatever the method returns.
Answers: 3
image
Computers and Technology, 22.06.2019 11:30, jcazares3558
Awell-diversified portfolio needs about 20-25 stocks from different categories.
Answers: 2
image
Computers and Technology, 23.06.2019 07:30, Braxtonw875
What part of the interface displays the external references contained in a selected cell? the status bar the review tab the scroll bar the formula bar
Answers: 1
image
Computers and Technology, 23.06.2019 19:00, amayax77
Write a program that displays the following menu: geometry calculator 1. calculate the area of a circle 2. calculate the area of a rectangle 3. calculate the area of a triangle 4. quit enter your choice (1-4): if the user enters 1, the program should ask for the radius of the circle and then display its area. use the following formula: area = ď€(the square of r) use 3.14159 for ď€ and the radius of the circle for r. if the user enters 2, the program should ask for the length and width of the rectangle and then display the rectangle’s area. use the following formula: area = length * width if the user enters 3, the program should ask for the length of the triangle’s base and its height, and then display its area. use the following formula: area = base * height * .5 if the user enters 4, the program should end. input validation: display an error message if the user enters a number outside the range of 1 through 4 when selecting an item from the menu. do not accept negative values for the circle’s radius, the rectangle’s length or width, or the triangle’s base or height. note: if the user enters an improper menu choice (1-4), the program prints "the valid choices are 1 through 4. run the program again and select one of those." if the user enters a negative radius, the program prints "the radius can not be less than zero." if the user enters a negative value for height or base, the program prints "only enter positive values for base and height."
Answers: 1
You know the right answer?
In C++ please. A company has sales reps that sell two different product lines. The sales amounts f...

Questions in other subjects:

Konu
Mathematics, 08.06.2021 18:50