1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
#include <iostream>
#include <iomanip>
using namespace std;
void inputData(int Act[], int Exp[], int size);
void printArray(int Act[], int Exp[], int size);
int running_total;
char sign;
int Poor =0;
int Distinquished = 0;
int Average = 0;
int Outstanding = 0;
int Commendable = 0;
int main()
{
int Exp[13] = {6, 7, 7, 5, 6, 6, 8, 7, 7, 6, 6, 7, 5};
int Act[13] = {0};
cout << "Get the data" << endl;
inputData(Exp, Act, 13);
cout << "***********************************************"
<< endl << endl;
printArray(Exp, Act, 13);
cout << "***********************************************"
<< endl << endl;
return 0;
}
void inputData(int Exp[], int Act[], int size)
{
int i;
for (i = 0; i < size; i++)
{
cout << "Week "<< i + 1 << " ( Expected Sales " << Exp[i] <<" ): ";
cin >> Act[i];
}
}
void printArray(int Exp[], int Act[], int size)
{
int var = 0;
string Rating ;
for (int i = 0; i < size; i++)
{
var = Act[i] - Exp[i];
if (var > 5) {Rating = "Distinquished";Distinquished++; }
else if ( -1 <= var && var <= 1) {Rating = "Average";Average++; }
else if (3 <var && var <=5) {Rating = "Outstanding";Outstanding++; }
else if (2 < var && var <=3) {Rating = "Commendable";Commendable++; }
else if (var <= -2) {Rating = "Poor";Poor++ ;}
// Add more if statements here
{
running_total=running_total+var;
if(running_total>0)
sign='+';
else if
(running_total<0)
sign='-';
}
cout<<setw(6)<< "Week "<< i + 1 << ":Exp: "<<Exp[i]<<":Act: "<< Act[i]<< "- Rating: "<< Rating<<sign<<running_total<<"(var:"<<var<<")"<<endl;
}
cout<<endl;
cout<<setw(6)<<"Totals:"<<endl;
cout<<setw(17)<<"Quarter Variance:"<<sign<<running_total<<endl;
cout<<setw(14)<<"Distinquished:"<<Distinquished<<endl;
cout<<setw(12)<<"Outstanding:"<<Outstanding<<endl;
cout<<setw(12)<<"Commendable:"<<Commendable<<endl;
cout<<setw(8)<<"Average:"<<Average<<endl;
cout<<setw(5)<<"Poor:"<<Poor<<endl;
}
|