![]() Math.random() only generates a decimal in between 0 and 1, including 0 and excluding 1. In order to randomly generate the opponent’s move, we can use Math.random(). Step 3: Randomly generate the opponent’s move. If it isn’t equal to rock, paper, or scissors, then we can print out a message to the user stating that their move wasn’t valid! Use a conditional to check whether myMove is equal to rock, paper, or scissors. Step 2: Check if the user entered a valid move. We store their input in a String called myMove. Next, we print out a message asking the user to type in rock, paper, or scissors using (). Step 1: Ask the user to enter in their move.įirst, we import the Scanner class to help us get input from the user, by adding import to the top of our program. If you want to develop with Graphical user interface you have to learn about java applets supports only for JDK version 8 or below or swings in java. ![]() This is below algorithm is for the rock, paper, scissior.
0 Comments
Leave a Reply. |