Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final int rock = 1;
- final int paper = 2;
- final int scissors = 3;
- int compthrow;
- int playerthrow;
- Scanner input = new Scanner(System.in);
- compthrow = (int)(3 * Math.random() + 1);
- System.out.print("Enter your throw ( 1 = rock, 2 = paper, 3 = scissors):");
- playerthrow = input.nextInt();
- System.out.print("Player Throws: ");
- switch(playerthrow){
- case rock: System.out.println("Rock");break;
- case paper: System.out.println("Paper");break;
- case scissors: System.out.println("Scissors");break;
- }//end switch
- System.out.print("Computer Throws: ");
- switch(compthrow){
- case rock: System.out.println("Rock");break;
- case paper: System.out.println("Paper");break;
- case scissors: System.out.println("Scissors");break;
- }//end switch
- if (playerthrow == rock && compthrow ==rock){
- System.out.println("its a draw");
- }else{
- if (playerthrow ==rock && compthrow == paper){
- System.out.println("comp wins");
- }else{
- if (playerthrow ==rock && compthrow == scissors){
- System.out.println("you wins");
- }
- }
- }//end else if
- if (playerthrow == paper && compthrow ==paper){
- System.out.println("its a draw");
- }else{
- if (playerthrow ==paper && compthrow == scissors){
- System.out.println("comp wins");
- }else{
- if (playerthrow ==paper && compthrow == rock){
- System.out.println("you wins");
- }
- }
- }//end else if
- if (playerthrow == scissors && compthrow ==scissors){
- System.out.println("its a draw");
- }else{
- if (playerthrow ==scissors && compthrow == rock){
- System.out.println("comp wins");
- }else{
- if (playerthrow ==scissors && compthrow == paper){
- System.out.println("you wins");
- }
- }
- }//end else if
Advertisement
Add Comment
Please, Sign In to add comment