Hi All,

I have an assignment that asks :
Write a program that prompts the user for test scores (doubles). The user enters -1 to stop the entry. After all of the test scores have been entered, calculate the average, the highest and the lowest test score. Use the code below as a template. Make sure you respond appropriately when no test scores are entered. Use the following screen shots as a guide.(I've attached the screen shots)

This is the template:

``````#include <iostream>
using namespace std;
int main()
{
double scores[75];
int counter = -1;
do
{
counter++;
cout << "Please enter a score (enter -1 to stop): ";
cin >> scores[counter];
} while (scores[counter] >= 0);
/*
CALCULATE AND DISPLAY THE AVERAGE
THE HIGHEST AND LOWEST TEST SCORE
BELOW HERE -- DO NOT MODIFY THE REST OF
PROGRAM EXCEPT TO PUT YOUR NAME ETC.
AT THE TOP. */
}``````

This is the code that I've come up with after hours of going through my textbook and surfing the web for information:

``````#include <iostream>
using namespace std;
int main()
{
double scores[75];
int counter = -1;
do
{
counter++;
cout <<"Please enter score (enter -1 to stop): ";
cin >> scores[counter];
}
while (scores[counter] >= 0);

double max_value = -10000, min_value = 10000, sum = 0;
average;
int max_index, min_index;

/* Add value to running total */
sum += scores[counter];

/* Compare value to current minimum */
if (scores[counter] < min_value);
{
min_value = scores[counter];
min_index = counter;
}

/* Compare value to current maximum */
if (scores[counter] > max_value);
{
max_value = scores[counter];
max_index = counter;
}

average = sum / scores[counter];
cout << "Average is " << average << endl;
cout << "Highest is " << max_value << endl;
cout << "Lowest is " << min_value << endl;
}``````

The problem is when I compile I get 2 warnings( "warning C4390: ';' : empty controlled statement found; is this the intent?" lines 24 and 31 ), but worst when entering grades, the program outputs the average, highest element and lowest element as -1. Also when -1 is entered first, it is supposed to exit, instead it again outputs the average, highest element and lowest element as -1 and then exits. :| I've been working really hard and am drawing a blank now. I'm a newb programmer, I know what the program is supposed to be doing, but what am I doing wrong in the code? How can I fix it? :?: Please help, I really want to learn! :confused:

Attachments
2
Contributors
1