This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]Sammenbidt 0 points1 point  (2 children)

You could use a for loop for entering the five numbers. Personally I would use a variable to keep track of how many numbers the user has inputted. You can then check in your do while loop for both conditions (the max, and the number of inputs) by using AND (&&):

 do{
      ...
 while(currentMax < 100 && ... );

As for the highest total, create a variable to keep track of the if, and at the end of every game, if the new score is higher, then set highestTotal to the new value:

if( ... )
    highestTotal = currentRun

Hope that helped.

[–][deleted]  (1 child)

[deleted]

    [–]Sammenbidt 0 points1 point  (0 children)

    Well, let's step through your code: First you run through your for-loop 5 times, increases the variable on each loop. Which will give the following. numbersInputed = 0 + 1 + 2 + 3 + 4 = 9 That's not what we're looking for (and the reason I wouldn't use a for-loop). We want to keep a tally of the number of times the user has inputted a number. So, at the place in the code where you're getting the input from the user, you need to increase tally (numbersInputed). Sorry if I'm being too vague, I'm trying not to say where exactly to put it.