i need help ive got this program which adds all the numbers up and displays it on the screen but now i am really stuck because the next thing i want to do is how to display it on the screen e.g. lets say ive entered 1,2,3,4,5,6 and the average is 3.5
i want my program to display all the numbers that i entered something like this
// function declaration
int GetValidPollution(int Day, GWindow& window);
void DrawHistogram(int level[], int count, GWindow& window);
int main()
{
GWindow Gwin;
int pollution_level[MAXDAYS];
double average=0.0;
int counter =0;
while (counter<MAXDAYS)
{
pollution_level[counter] = GetValidPollution(counter, Gwin);
average = average + pollution_level[counter];
counter++;
}
DrawHistogram(pollution_level, MAXDAYS,Gwin);
Gwin.setPenColour(BLACK);
Gwin.writeText(0, 10, "The average pollution level over those 6 days was :");
Gwin.writeDouble(400, 10,average/MAXDAYS);
// Finally, wait for a key to be pressed
Keyboard.waitKey();
return 0;
}
//function definition
int GetValidPollution(int Day, GWindow& window)
{
int FailCounter=0;
int testvalue=0;
window.clear();
window.setPenColour(BLACK);
window.writeText(0,20,"Enter pollution level for day ");
window.writeInt(190,20,Day);
window.writeText(200,20," range (1-100): ");
testvalue = window.readInt();
while ((testvalue<1)||(testvalue>100))
{
window.clear();
window.setPenColour(RED);
FailCounter++;
if (FailCounter==1)
{
window.writeText(0,50, "Number is incorrect Enter between 1 and 100");
}
if (FailCounter==2)
{
window.writeText(0,50, "ENTER BETWEEN 1 AND 100");
}
if (FailCounter>=3)
{
window.writeText(0,50, "GO AWAY!!");
}
window.writeText(0,20,"Enter pollution level for day ");
window.writeInt(190,20,Day);
window.writeText(200,20," range (1-100): ");
testvalue = window.readInt();
}
return testvalue;
}
void DrawHistogram(int level[], int count, GWindow& window)
{
while (count=0)
{
window.writeInt(0,50,level[count]);
}
}
basically the lines im most worried about is the bold ones ive got this program where its working perfectly fine accept the thing i have to show which is in a fucntion