I am writing a program that accepts an input file of 10 items each having revenue across 4 quarters. In this particular function I have to determine if the items profit has steadily increased, decreased or went up and down across the 4 columns, or quarters(qu) as they are referenced in my code.
I was able to cout whether the item increased or decreased across the 4 quarters but cannot seem to figure out how to record those instances and determine and display on screen if they went up, down or both. Below is my function with data file. Thank you in advance for any help you can provide.
void steady(string item[], double revenue[][4])
{
double max;
const int NUM_ROWS=10;
const int NUM_COLS=4;
string iteminc;
string itemdec;
cout << "\nRevenue path per item across 4 quarters: \n";
for(int i=0;i<NUM_ROWS;i++) /*Items*/
{
max=0;
for(int qu=0;qu<NUM_COLS;qu++) /*Quarters*/
{
if(max<revenue[i][qu])
{
max=revenue[i][qu];
iteminc=item[i]; /*Display Item*/
cout << iteminc << " = " << "Icreased \n";
}
if(max>revenue[i][qu])
{
max = revenue[i][qu];
itemdec=item[i]; /*Display Item*/
cout << itemdec << " = " << "Decreased \n";
}
}
}
}
Input Data File:
Memory 5 15 20 26
CPU 10 21 20 0
Monitor 2 17 4 42
HD 5 -8 -10 -4
Keyboards 7 10 15 -9
Mice 3 -10 3 10
Drives -1 -11 -12 -14
Software 3 5 10 8
Optical 5 7 -8 10
Printers -19 3 7 11