Question: These are the two problems I'm working with in C++. I have the output problem solved and now I am attempting to read in the

These are the two problems I'm working with in C++. I have the output problem solved and now I am attempting to read in the file created from this first problem, and then calculate the data.

Corporate Sales Data Output

Write a program that uses a structure to store the following data on a company division:

Division Name (such as East, West, North, or South)

Quarter (1, 2, 3, or 4)

Quarterly Sales

The user should be asked for the four quarters sales figures for the East, West, North, and South divisions. The data for each quarter for each division should be written to a file.

Input Validation: Do not accept negative numbers for any sales figures.

Corporate Sales Data Input

Write a program that reads the data in the file created by the program in Programming Challenge 11. The program should calculate and display the following figures:

Total corporate sales for each quarter

Total yearly sales for each division

Total yearly corporate sales

Average quarterly sales for the divisions

The highest and lowest quarters for the corporation

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

I have done the first problem, the Corporate Sales Data Output.

I am not sure how to read the file in from the output problem, and then perform the functions it asks for in the Input problem.

This is what I have for the Output problem:

cout<<"Corporate Sales Data Output"<> c.name; out << c.name << " "; for(int j = 0; j < 4; j++) { cout << "Enter the quarter number(1-4): "; cin >> c.quarter[i]; out << c.quarter[i] << " "; cout << "Enter quarter "<< j + 1 << " sales: "; cin >> c.sales[i]; if(c.sales[i] < 0) { cout<<"Enter only positive sales: "; cin>> c.sales[i]; } out << c.sales[i] << " "; if(j == 3) { out << "|"; } } } cout << "Sales data has been written to the file named " "corporateData.txt " << endl; } out.close();

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

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

This is what I have for the input problem so far:

cout<<"Corporate Sales Data Input"<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!