Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello , Can you please help me with this? Please, I want I new code, not copy. T

ID: 3920126 • Letter: H

Question

Hello ,

Can you please help me with this?

Please, I want I new code, not copy.  

The Dayton Fire & Brimstone company has asked you to write a program which will produce a report, in chart form, showing how their four divisions are doing this year in generating sales. Each division has five sales territories.

The four divisions are East Coast, Mid-West, Far-West, and West Coast.

In main:

-have the user enter a file name for a text file which will hold the sales for all divisions and their territories; define a vector to hold the division names and an array of doubles to hold each of the four division's sales total.

-call a function which repeatedly has the user enter a division name and place it in the vector, and then enters the division’s five sales amounts and places each of them into the text file, using the division name as a prompt. Validate that each sales amount is zero or greater.

-call a second function which processes the file by summing the sales of each division and placing the total into the array of divisional sales totals.

-in main: process the divisional totals array by producing the following sales chart:

-display a Sales Chart title line

-display a single line for each division, showing:

>the division’s name

>the division’s total sales amount

>an asterisk (*) for each $1,000 in sales, e.g., $3, 500 in sales would show: * * *

-also determine the division with the most sales

After the sales chart is displayed, display the division name and sales amount of the division with the most sales.

Note: arrays and files must be processed with loops, and any vector statements or functions must be from Chapter 7 of our textbook.

Use this data for the screen print:

East Coast: $800, $1,200, $2,000, $500, $2,500

Mid-West: $1,000, $3,000, $2,500, $5,000, $1,500

Far-West: $50, $150, $400, $200, $199

West Coast: $200, $0, $500, $100, $201

Explanation / Answer

#include<iostream>

#include<vector>

#include<fstream>

#include<string>

using namespace std;

void read_user_input(string name,vector<string> &vec, vector<double> &sales);

void total_sales(double total_sale[],vector<string> vec, vector<double> sales);

int main()

{

vector<string> names;

vector<double> sales;

string file_name;

double total_sale[4];

//ask user to enter file name

cout << "Enter file name to store information: ";

cin >> file_name;

//call function to read input from user and write to file

read_user_input(file_name,names, sales);

//call function to get total_sales for each divcision

total_sales(total_sale,names, sales);

//display sales report

for (int i = 0; i < names.size(); i++)

{

cout << names[i] << " ";

long quotient;

quotient = (long)total_sale[i] /1000;

for (int k = 0; k < quotient; k++)

{

cout << "*";

}

cout << endl;

}

//find maximum total_sale and display

double max_total_sale = total_sale[0];

int index;

for (int i = 0; i < 4; i++)

{

if (max_total_sale < total_sale[i])

{

max_total_sale = total_sale[i];

index = i;

}

}

cout << "Division name with the most sales: " << names[index]<<" sales: $"<<max_total_sale << endl;

}

void read_user_input(string file_name,vector<string> &names, vector<double> &sales)

{

string name;

double amt;

int n;

ofstream out;

//open specified file for writing

out.open(file_name);

if (!out)

{

cout << "Not able to open file for writing" << endl;

exit(-1);

}

//theare are four division ,take input from user.

for(int i = 0; i < 4 ; i++)

{

cin.ignore();

cout << "Enter division name: ";

getline(cin,name);

//cout << "Enter number of sales : ";

//cin >> n;

//psuh name to vector names

names.push_back(name);

out << names[i] << ":";

for (int j = 0; j < 5; j++)

{

cout << name << ":";

cin >> amt;

if (amt >= 0)

{

//push sales to sales vector and to file

sales.push_back(amt);

out << "$";

//output sales to file separated by ,

if(i < 4)

out << sales[j] << ",";

}

else

{

cout << "sales value must be greater than or equal to zero" << endl;

--j;

continue;

}

}

cout << endl;

}

}

void total_sales(double total_sale[],vector<string> names, vector<double> sales)

{

double sum;

int j = 0;

for (int i = 0; i < names.size(); i++)

{

while(j < 20)

{

sum = 0;

for (int k =j; k < j+5; k++)

{

sum += sales[k];

}

j += 5;

break;

}

total_sale[i] = sum;

}

}

---------------------------------------------------------------------

//output

Enter file name to store information: SalesInfo.txt
Enter division name: East Coast
East Coast:800
East Coast:1200
East Coast:2000
East Coast:500
East Coast:2500
Enter division name: Mid-West
Mid-West:1000
Mid-West:3000
Mid-West:2500
Mid-West:5000
Mid-West:1500
Enter division name: Far-West
Far-West:50
Far-West:150
Far-West:400
Far-West:200
Far-West:199
Enter division name: West Coast
West Coast:200
West Coast:0
West Coast:500
West Coast:100
West Coast:201
East Coast *******
Mid-West *************
Far-West
West Coast *
Division name with the most sales: Mid-West sales: $13000

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote