I'm trying to make a program to play rock, paper, scissors with a computer.
However, part of the assignment is having the player choose the amount of rounds to play with the computer. If there is a tie, the round is not supposed to count towards the game.
My code looks like this -- I'm more focused on the for part of the program:
int gamePlays = 0;
for (int = 0; i < gamePlays; i++)
{
// If, else if, and else statements to make the game possible.
// Here is an example of part of the code:
if (cpuChoice.equals ("rock"))
{
if (userChoice.equals ("scissors"))
{
System.out.println("Rock beats scissors, computer wins.");
}
else if (userChoice.equals ("paper"))
{
System.out.println("Paper beats rock, computer wins.");
}
else
{
System.out.println("You both chose rock! It's a tie.");
}
// The rest would else if cpuChoice.equals "paper" and else.
}
How do I exclude the last else statement when it's a tie from the counter?
I've wrestled with this for a couple hours and can't find any solutions.
Aucun commentaire:
Enregistrer un commentaire