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

Sales data should be stored in a struct variable of type SalesType , which has s

ID: 3685634 • Letter: S

Question

Sales data should be stored in a struct variable of type SalesType, which has six components: LastName, FirstName,and Region of type string, MonthlySales of type float, Status of type string, and HighSales of type boolean.

Use this file:

Savoy Daron Fairfield 1,803.52 Stevenson Shaniya Vacaville 1,571.06 Langlois Darin Fairfield 2,012.06 Layne Casandra Vacaville 2,101.25 Backus Felipe Fairfield 3,852.00 Anderson Andrew Vacaville 2,510.75 Brody Irwin Vacaville 3,299.77 Polanco Belva Dixon 2,025.00 Cummings Savanna Dixon 1,906.78 Nevarez Cecile Fairfield 1,628.47 Winfrey Humberto Vacaville 1,470.88 Quinn Shamika Vallejo 5,874.19 Crocker Leanne Vacaville 1,598.63 Strassberg Gerson Vallejo 1,835.16 Mcnair Alena Fairfield 1,250.00 Harper Brennon Fairfield 998.09 Tomlin Ellen Vallejo 877.25 Zeller Lavern Elmira 1,103.16 Barnett Rosalyn Vallejo 2,657.81 Couture Tremayne Fairfield 1,408.85 Mccool Deon Fairfield 1,549.13 Powell Neta Fairfield 1,515.94 Steel Fletcher Fairfield 1,155.69 Anderson Valary Vacaville 2,873.75 Brown Michael Fairfield 1,956.94 Youngblood Maribeth Fairfield 1,704.55 Cedeno Dusty Vallejo 3,675.75 Flanagan Giselle Fairfield 1,512.50 Cosgrove Mitch Fairfield 551.25 Lear Shande Vallejo 1,438.83 Field Jill Suisun 1,208.22 Ellington Jame Fairfield 2,656.25 Layman Lanny Suisun 4,500.00 Mccormick Sonia Fairfield 1,759.80 Knapp Zelda Vacaville 1,542.75 Hogg Darrien Fairfield 2,153.78 Rey Alvino Vacaville 2,408.25 Ridley Fannie Fairfield 1,391.50 Wheaton Ronnie Fairfield 1,776.00 Crandall Walker Fairfield 945.56 Garero Devon Vacaville 1,460.81 Rupert Barrett Fairfield 3,464.50 Johnsen Damian Dixon 2,088.28 Wildon Sarah Pinole 2,420.00 Ruff Alma Vallejo 2,326.20 Kearns Ashanti Fairfield 975.00 Donohue Brook Vallejo 1,819.13 Lopez Dudley Suisun 3,506.75 Larue Emogene Fairfield 2,964.50 Beatty Jaylene Fairfield 1,956.94 Walsh Joe Fairfield 1,708.88 Hoyt Laquita Vallejo 1,917.39 Gaddis Rand Vacaville 2,370.38 Dillon Trena Vallejo 1,339.55 Simpson Ona Rio Vista 1,733.44 Conger Garett Fairfield 2,281.31 Lanham Malcolm Vallejo 898.44 Tindall Jacob Travis 4,800.00 Parkinson Carl Pinole 2,420.00 Warez Amber Fairfield 2,468.97

Address, City, Amount

Read the problem. Write a program that reads sales data from individual sales associates, calculates their standing, determines the associate with the highest sales, and writes the data to a text file.

Sales data should be stored in a struct variable of type SalesType, which has six components: LastName, FirstName,and Region of type string, MonthlySales of type float, Status of type string, and HighSales of type boolean.

Use this file:

Savoy Daron Fairfield 1,803.52 Stevenson Shaniya Vacaville 1,571.06 Langlois Darin Fairfield 2,012.06 Layne Casandra Vacaville 2,101.25 Backus Felipe Fairfield 3,852.00 Anderson Andrew Vacaville 2,510.75 Brody Irwin Vacaville 3,299.77 Polanco Belva Dixon 2,025.00 Cummings Savanna Dixon 1,906.78 Nevarez Cecile Fairfield 1,628.47 Winfrey Humberto Vacaville 1,470.88 Quinn Shamika Vallejo 5,874.19 Crocker Leanne Vacaville 1,598.63 Strassberg Gerson Vallejo 1,835.16 Mcnair Alena Fairfield 1,250.00 Harper Brennon Fairfield 998.09 Tomlin Ellen Vallejo 877.25 Zeller Lavern Elmira 1,103.16 Barnett Rosalyn Vallejo 2,657.81 Couture Tremayne Fairfield 1,408.85 Mccool Deon Fairfield 1,549.13 Powell Neta Fairfield 1,515.94 Steel Fletcher Fairfield 1,155.69 Anderson Valary Vacaville 2,873.75 Brown Michael Fairfield 1,956.94 Youngblood Maribeth Fairfield 1,704.55 Cedeno Dusty Vallejo 3,675.75 Flanagan Giselle Fairfield 1,512.50 Cosgrove Mitch Fairfield 551.25 Lear Shande Vallejo 1,438.83 Field Jill Suisun 1,208.22 Ellington Jame Fairfield 2,656.25 Layman Lanny Suisun 4,500.00 Mccormick Sonia Fairfield 1,759.80 Knapp Zelda Vacaville 1,542.75 Hogg Darrien Fairfield 2,153.78 Rey Alvino Vacaville 2,408.25 Ridley Fannie Fairfield 1,391.50 Wheaton Ronnie Fairfield 1,776.00 Crandall Walker Fairfield 945.56 Garero Devon Vacaville 1,460.81 Rupert Barrett Fairfield 3,464.50 Johnsen Damian Dixon 2,088.28 Wildon Sarah Pinole 2,420.00 Ruff Alma Vallejo 2,326.20 Kearns Ashanti Fairfield 975.00 Donohue Brook Vallejo 1,819.13 Lopez Dudley Suisun 3,506.75 Larue Emogene Fairfield 2,964.50 Beatty Jaylene Fairfield 1,956.94 Walsh Joe Fairfield 1,708.88 Hoyt Laquita Vallejo 1,917.39 Gaddis Rand Vacaville 2,370.38 Dillon Trena Vallejo 1,339.55 Simpson Ona Rio Vista 1,733.44 Conger Garett Fairfield 2,281.31 Lanham Malcolm Vallejo 898.44 Tindall Jacob Travis 4,800.00 Parkinson Carl Pinole 2,420.00 Warez Amber Fairfield 2,468.97

Address, City, Amount

The file contains 60 records. Load the records into an array of type SalesType containing 60 elements. Your program must contain at least the following functions: a. A function to read the sales data into the array. b. A function to assign the relevant Status to each sales associate. c. A function to find the highest sales. d. A function to print the sales data. Determine the sales associate's Status using the following table: $0 - 999.99 Unacceptable $1000.00 - 1999.99 Poor $2000.00 - 2999.99 Good $3000.00 - 3999.99 Excellent $4000.00 - above Outstanding The output file should be a text file with the following data: LastName, FirstName, Region, MonthlySales and Status. Each of these items should be separated by 3 spaces. Each sales associate's record should be on a separate line in the file. The sales associate, or associates with the highest monthly sales should have the text "Performer" appended to their record (separated from the Status by 1 space). Other than declaring the variables and opening the input and output files, the function main should only be a collection of function calls. 2. Pseudocode. I strongly suggest that before you start programming the solution, that you write pseudocode to insure that you understand the problem. You are not required to submit your pseudocode for this lab. 3. Create a new project. Visual C++ Win32 Console Application Name the project CIS022_S2016_Lab9a your name Select a location where you can find it later Choose the default application settings 4. Write the program. Write code that solves the problem described in item 1. Pause the program so that the console does not disappear until a key is pressed. 5. Insure that you properly document your code.

Explanation / Answer

Write a program that reads sales data from individual sales associates

#include <iostream>

#include <fstream>

using namespace std;

//Constant array size declaration.

const int LOCATIONS = 20;

//Function Prototypes

void readData(double a[], double& data);

int main()

{

//Variable declarations

ifstream in;

char in_file[256];

double salesData[LOCATIONS], totalSales, data;

//Prompts the user for the input file name.

cout << "Enter the input file name: ";

cin >> in_file;

// Opens the stream and connects to the file.

in.open(in_file);

//Checks to see if the input file opened properly.

//Displays an error message if file not opened.

if(in.fail( ))

{

cout << "Input file opening failed. ";

exit(1);

}

readData(salesData, data);

cout << endl << "The stored data is " << data << endl;

in >> data;

in.close( );

return 0;

}

//Read data function.

void readData(double a[], double& data)

{  

   ifstream in;

   int next, index;

   while (in >> next)

   a[index] = next;

   index++;  

}

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