1 import java.io.*;
  2 
  3 public class NewMain10 {
  4 
  5     static String userChoiceWord, compChoiceWord;//will store the users choice and computer's choice - global so methods can access them
  6     static int tie, win, loss;//will store number of ties, wins & losses
  7     static int userChoice, compChoice;//stores the int value that will be analyzed by determineOutcome()
  8     static int randNum;//will store random number
  9 
 10     public static void main (String args []) throws IOException
 11     {
 12         BufferedReader br = new BufferedReader (new InputStreamReader (System.in));// user input
 13 
 14         int playAgain;
 15         playAgain=1;//starts up the first play again loop
 16         userChoiceWord="0";//sets strings equal to something in order to run
 17         compChoiceWord="0";
 18 
 19 
 20         System.out.println("ROCK PAPER SCISSORS");
 21         System.out.println("===================");
 22 
 23         do{//will repeat from here
 24             System.out.println();
 25             System.out.println("1=Rock");
 26             System.out.println("2=Paper");
 27             System.out.println("3=Scissors");
 28             System.out.println("===========");
 29             System.out.println("Choose:");
 30             userChoice = Integer.parseInt(br.readLine());//user enters their choice
 31             System.out.println();
 32 
 33             if(userChoice==1){//assigns a word to the users choice
 34             userChoiceWord=("Rock.");}
 35             if(userChoice==2){
 36             userChoiceWord=("Paper.");}
 37             if(userChoice==3){
 38             userChoiceWord=("Scissors.");}
 39 
 40             compChoice=randomWholeNumber(randNum);//sets the compChoice to the randNum
 41 
 42             if(compChoice==1){//assigns a word to the computers choice
 43             compChoiceWord=("Rock.");}
 44             if(compChoice==2){
 45             compChoiceWord=("Paper.");}
 46             if(compChoice==3){
 47             compChoiceWord=("Scissors.");}
 48 
 49             System.out.println("You have chosen "+userChoiceWord);//prints out the choices
 50             System.out.println("The computer has chosen "+compChoiceWord);
 51 
 52             if(userChoice==compChoice){//if the choices are the same, theres a tie
 53             tie=tie+1;}//stores number of ties
 54             if(((userChoice==1)&&(compChoice==2))||((userChoice==2)&&(compChoice==3))||((userChoice==3)&&(compChoice==1))){//lose conditions
 55             loss=loss+1;}//stores the number of losses
 56             if(((userChoice==1)&&(compChoice==3))||((userChoice==2)&&(compChoice==1))||((userChoice==3)&&(compChoice==2))){//win conditions
 57             win=win+1;}//stores number of wins
 58 
 59             System.out.println();
 60             System.out.println(determineOutcome(tie, loss, win, userChoice, compChoice));
 61 
 62             System.out.println();
 63             System.out.println("WINS: "+win);//displays stats
 64             System.out.println("LOSSES: "+loss);
 65             System.out.println("TIES: "+tie);
 66             System.out.println();
 67             System.out.println("Press 1 to play again.");
 68             playAgain=Integer.parseInt(br.readLine());//user decides to play again
 69         
 70         }while(playAgain==1);//play again = 1, repeat program at do
 71 
 72  }//closes main
 73 
 74 
 75  public static int randomWholeNumber(int randNum){
 76 
 77     randNum = (int) ((Math.random()*3)+1);
 78     return (randNum);//gets a random computer choice
 79 
 80  }//closes randomWholeNumber
 81 
 82  public static String determineOutcome(int tie, int loss, int win, int userChoice, int compChoice){
 83 
 84     if(userChoice==compChoice)
 85     {//if the choices are the same, theres a tie
 86     return "YOU'VE TIED";
 87     }
 88 
 89     if(((userChoice==1)&&(compChoice==2))||((userChoice==2)&&(compChoice==3))||((userChoice==3)&&(compChoice==1))){//lose conditions
 90     return "YOU LOSE";
 91     }
 92 
 93     if(((userChoice==1)&&(compChoice==3))||((userChoice==2)&&(compChoice==1))||((userChoice==3)&&(compChoice==2))){//win conditions
 94     return "YOU WIN";
 95     }
 96 
 97     else{
 98     return "error";}
 99 
100  }
101 
102 }
103