I'm doing some review for class but I ran into a problem on the last for loop. It is supposed to find the difference between the sales quarters. Quarter 1 to Quarter 2 to Quarter 2 to 3 and 3 to 4 the company lost or made this much money. I'm not sure what I am doing wrong because I get something that looks like scientific notation.
// System Libraries
#include <iostream>
#include <iomanip>
usingnamespace std;
constint DIV = 6;
constint QUA = 4;
int main()
{
float salesAmount;
float division[QUA][DIV];
cout << "Enter the sales for the following Divisions for the quarter. " << endl;
cout << endl << endl;
// This part of the program has the user enter data
for ( int d = 0; d < DIV; d++)
{
for( int q = 0; q < QUA; q++)
{
cout << "Please enter the quarterly sales for Division: " << d +1
<< " Quarter: " << q + 1 ;
cout << endl << "$ " ;
cin >> division[q][d];
if (division[q][d] < 0)
{
cout << "That is not a valid number. Try again." << endl;
cin >> division[q][d];
}
}
}
cout << endl << endl;
// This part displays the information entered
for (int a = 0; a < DIV; a++)
{
cout << "The quarterly sales for Division were " << a +1 << endl;
for (int b = 0; b < QUA; b++)
{
cout << "$ " ;
cout << division[b][a] << endl;
}
}
cout << endl << endl;
// This part calculated the increase and decrease for the quarters of each division
for (int e = 0; e < DIV; e++)
{
cout << "The quarterly sales increase/decrease for Division were " << e +1 << endl << endl;
for (int f = 1; f < QUA; f++)
{
cout << "Quarter: " << f << " to Quarter: " << f+1 << endl;
cout << "$ " ;
cout <<right << showpoint << division[f][e] - division[f-1][e] << endl;
}
}
//Shows the total amount made by the division
for (int g = 0; g < DIV; g++)
{
for (int h = 0; h < 1; h++)
{
cout << "The total sales were "
<< (division[h][g] + division[h+1][g] + division[h+2][g] + division[h+3][g]);
cout << endl;
}
}
cout << endl << endl;
//The company's quarter sales increase and decrease.
for (int j = 0; j < QUA; j++)
{
cout << "The company's increase/decrease for the quarter " << j +1 ;
for (int k = 0; k < 1; k++)
{
cout << ((division[k][j] + division[k][j+1] + division[k][j+2] + division[k][j+3]) -
(division[k-1][j] + division[k-1][j+1] + division[k-1][j+2] + division[k-1][j+3]));
cout << endl;
}
}
cin.ignore();
cin.get();
return 0;
}