4/2 How do I make this "between"thing?


#1

This is what I have to do:
1. If computerChoice is between 0 and 0.33, make computerChoice equal to "rock".
2.If computerChoice is between 0.34 and 0.66, make computerChoice equal to "paper".
3.If computerChoice is between 0.67 and 1, make computerChoice equal to "scissors".
But there are three outcomes! Using if / else only lets us have two outcomes. What now?! We need to use if / else if / else. See the hint for the full syntax. You will laugh at how easy it is.

So how do I make that between thing?


#2

you aren't really using a symbol to designate "Between".
You only have to tell the program not to go past certain points so for your first one, since we know the computer is going to generate a number between 0 and 1 it would look something like:

if (computerChoice < 0.34) { ///this states "if computerChoice is less than 0.34". Which is the 
                             ///same as saying between 0 and 0.33 since the computer won't give
                             ///a number that is less than 0 or greater than 1
    computerChoice = "rock";
}

hope this is helpful. Also one more hint to help you with the middle one since human logic differs from computer logic:

if (condition) { ////the computer looks at this first. If the condition is met the computer goes
    do something; ///here and stops looking at your other else if statements
}
else if (condition) { ///if the first condition is not met THEN the computer comes here and if this condition is met
    do something different; ///it then does this
}
else { ///if none of the other conditions is met the computer defaults to coming here which is why you don't give else statements conditions
    do something; ///and it proceeds to do this
}

good luck and keep coding