This question has largely already been posted, and I apologize for that. However, I cannot get the max an min values to change from anything except -1. I'd love to make them actually work; I feel like the comparison statements are correct. I know the counter is working properly, and I know the sum works.
Arrays are not my friend thus far, and help would be greatly appreciated. Here's the code:
#include <iostream>
using namespace std;
//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.
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.
double sum = 0;
double average;
double max_value = scores[counter];
double min_value = scores[counter];
int y;
for (int y = 0; y < counter; y++)
{
sum+=scores[y];
}
cout<<"Sum: "<<sum<<endl;
// average
average = sum/counter;
cout<<"Average: "<<average<<endl;
for (int y=0; y< counter; y++)
{
// min value
if (scores[counter] < min_value)
{
min_value = scores[counter];
}
// max value
if (scores[counter] > max_value)
{
max_value = scores[counter];
}
}
cout<<"Min value: "<<min_value<<endl;
cout<<"Max value: "<<max_value<<endl;
}
I cannot change anything above the allcaps comment, but I shouldn't need to. Why won't the max and min change? If I could get an explanation and not just code, that'd be great. Thanks.