Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

rock paper scissor in java

if (personPlay.equals(computerPlay)) {
   System.out.println("It's a tie!");
}
else if (personPlay.equals("R")) {
   if (computerPlay.equals("S")) 
      System.out.println("Rock crushes scissors. You win!!");
   else if (computerPlay.equals("P")) 
        System.out.println("Paper eats rock. You lose!!");
}
else if (personPlay.equals("P")) {
   if (computerPlay.equals("S")) 
       System.out.println("Scissor cuts paper. You lose!!"); 
   else if (computerPlay.equals("R")) 
        System.out.println("Paper eats rock. You win!!");
} 
else if (personPlay.equals("S")) {
     if (computerPlay.equals("P")) 
         System.out.println("Scissor cuts paper. You win!!"); 
     else if (computerPlay.equals("R")) 
        System.out.println("Rock breaks scissors. You lose!!");
}
else 
     System.out.println("Invalid user input.");
Comment

PREVIOUS NEXT
Code Example
Java :: hash table implementation java 
Java :: abstraction in java 
Java :: Error: Could not find or load main class javafx.controls,javafx.fxml Caused by: java.lang.ClassNotFoundException: javafx.controls,javafx.fxml 
Java :: java random number generator in range 
Java :: switch case enum java 
Java :: how to check if user is logged in firebase android and then load another activity 
Java :: map in java 
Java :: integer.tobinarystring returns 
Java :: how to stop activity from another activity 
Java :: remove duplicate from string 
Java :: rainbow six 
Java :: arraylist index java 
Java :: what is var in java 
Java :: button onclick java 
Java :: java ignore catch 
Java :: throw and throws keyword in java 
Java :: check if a char is a space java 
Java :: sound file java 
Java :: atm machine java project 
Java :: spring 5 jdbctemplate query for a single value 
Java :: java not equal to 
Java :: java set 
Java :: java string join 
Java :: get all enum values java 
Java :: check if optional is empty java 
Java :: java object into list 
Java :: How to activate an entity listener for all entities 
Java :: initializing list in java 
Java :: convert linkedlist to integer array java 
Java :: bukkit console filter 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =