“Write a C++ program (use multi-dimensional arrays) that uses an array structures (size 8) to store the following information on a company’s 8 divisions:
Division name (such as East, West, North, South, Northeast, Northwest, Southeast, and Southwest)
First Quarter sales
Second quarter sales
Third quarter sales
Fourth Quarter Sales
Fourth Quarter sales
Total annual sales
Average quarterly sales
Each array element should contain all information about one of the eight divisions (East, West, North, etc.). The user should be asked for the four quarters’ sales figures for each division. (You are allowed to store user input data in an input file, if you wish). Each division’s total and average sales should be calculated and stored in the appropriate member field. Once all data are filled, print a report to a file displaying all information for all 8 divisions.
NB. Print your report in descending order of Average quarterly sales.
Do not allow the user to input negative values for any of the sales figures.”
----------------------------------------------------------------------------------
#include <iomanip>
#include <iostream>
#include <fstream>
using namespace std;
struct Comp;
float first;
float second;
float third;
float val;
float avg;
string const N = "North Division";
string const S = "South Division";
string const E = "East Division";
string const W = "West Division";
string const NW = "North West Division";
string const NE = "North East Division";
string const SW = " South West Division";
string const SE = " South East Division";
int main()
{
ofsttream outFile;
outFile.open ("outsales.dat")
Comp div[8]
div [0].name= N;
div [1].name= S;
div [2].name= E;
div [3].name= W;
div [4].name= NW;
div [5].name= NE;
div [6].name= SW;
div [7].name = SE;
outFile<<setw(10)<< "Division"<<setw(15)<<"First Quarter"<<setw(15)<<"Second Quarter"<<setw(15)<<"Third Quarter"<<setw(15)<<"Fourth Quarter"<<setw(15)<<"Total"<<setw(15)<<"Average"<<endl;
for (int j=0; j<8; j++)
{ outFile<<setw(15)<<div[j].name;
cout<< "Please enter First Qrt Sales"<<div[j].name<<endl;
cin>>div[j].fir;
if (div[j].fir<1)
{
cout<< "You can only enter postive numbers!!"<<endl;
}
outFile<<fixed<<showpoint<<setprecision(2)<<setw(15)<<div[j].fir<<endl;
cout<< "Please enter Second Qrt Sales"<<div[j].name<<endl;
cin>>div[j].sec;
if (div[j].sec<1)
{
cout<< "You can only enter postive numbers!!"<<endl;
}
outFile<<fixed<<showpoint<<setprecision(2)<<setw(15)<<div[j].sec<<endl;
cout<< "Please enter Third Qrt Sales"<<div[j].name<<endl;
cin>>div[j].thir;
if (div[j].thir<1)
{
cout<< "You can only enter postive numbers!!"<<endl;
break;
}
outFile<<fixed<<showpoint<<setprecision(2)<<setw(15)<<div[j].thir<<endl;
cout<< "Please enter Fourth Qrt Sales"<<div[j].name<<endl;
cin>>div[j].four;
if (div[j].four<1)
{
cout<< "You can only enter postive numbers!!"<<endl;
break;
}
outFile<<fixed<<showpoint<<setprecision(2)<<setw(15)<<div[j].four<<endl;
div [j].total= (div[j].four + div[j].thir + div[j].sec + div[j].fir);
outFile<<setw(15)<<div[j].total;
div[j].avg = (div[j].total)/4;
outFile<<setw(15)<<div[j].avg<<endl;
}
void BubbleSort (Comp div[], int size)
{
bool QrtSal= true;
while (QrtSal)
{
QrtSal=false;
for (int j=0; j<size + 1; --j)
if (avg (div[j]<avg(div[j-1))
{ Comp qrt = div [j-1]; div [j-1]=div[j]; div [j-1]= Comp;
QrtSal=true;
}
}
}
return 0;
}
----------------------------------------------------------------------------------
Good day: I have a lot of things going on here...i'm lost...I'm getting compiler errors such as:
1. error C2065: 'ofsttream' : undeclared identifier
2. error C2275: 'Comp' : illegal use of this type as an expression
3. error C2228: left of '.name' must have class/struct/union
4. error C2275: 'Comp' : illegal use of this type as an expression
5. error C2036: 'Comp []' : unknown size
There are too many errors for me to list. But can you see what I'm doing wrong?
Thank you and have a good day.
5.