Java Reference
In-Depth Information
1.
Declare the variables.
2.
Initialize the variables.
3.
Display the rules.
4.
Prompt the users to play the game.
5.
Get the users' responses to play the game.
6.
while
(response is yes)
Main
Algorithm
{
a.
Prompt player 1 to make a selection.
b.
Get the play for player 1.
c.
Prompt player 2 to make a selection.
d.
Get the play for player 2.
e.
If both the plays are legal
{
i.
Retrieve both plays.
ii.
Increment the total game count.
iii.
Declare the winner of the game.
iv.
Increment the winner's game win count by 1.
}
f.
Prompt the users to determine whether they want to play again.
g.
Get the players' responses.
}
7.
Output the game results.
PROGRAM LISTING
import
java.util.*;
public class
GameRockPaperScissors
{
static
Scanner console =
new
Scanner(System.in);
public static void
main(String[] args)
{
//Step 1
int
gameCount;
//to count the number of
//games played
int
winCount1;
//to count the number of
//games won by player 1
int
winCount2;
//to count the number of
//games won by player 2
Search WWH ::
Custom Search