C++/Calculating highest and lowest test scores without arrays.
I am to input data that looks like this, with the negative numbers dividing the sections:
I am to calculate the highest,lowest for each section. My problem is trying to find out how to get the lowest and highest grade for each section.
Doing this kind of program without using arrays is a bit of a pain, but still easily done. The first thing you need to do is create two variables: grade_highest and grade_lowest. Then read in the first number, and set both grade_highest and grade_lowest equal to that value. Being the first number in the list, it is both the highest and lowest grade. The next step will be to look at the next number. If it's higher than the highest grade, reset grade_highest to the new number. If it's lower than the lowest grade, reset grade_lowest to the new number. If, however, the number is less than 0 you'll want to print out onto the screen the current values of grade_highest and grade_lowest, then set both of their value equal to zero. This will make sure that the program is not going to compare the values from the previous section with the new section. You're going to have to use a series of 'if' statements, with the first 'if' statement checking to see if the value of the number is less than zero. If the number isn't less than zero, you'll have some more 'if' statements nested within the 'else' portion of the 'if' statement. It seems kinda complicated, but it's not bad at all. If you have any further questions, please let me know.
Best Of Luck,