Guest User

TAKETHISNIGGA

a guest
Feb 23rd, 2012
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. final int rock = 1;
  2. final int paper = 2;
  3. final int scissors = 3;
  4. int compthrow;
  5. int playerthrow;
  6. Scanner input = new Scanner(System.in);
  7.  
  8. compthrow = (int)(3 * Math.random() + 1);
  9.  
  10. System.out.print("Enter your throw ( 1 = rock, 2 = paper, 3 = scissors):");
  11. playerthrow = input.nextInt();
  12.  
  13. System.out.print("Player Throws: ");
  14. switch(playerthrow){
  15. case rock: System.out.println("Rock");break;
  16. case paper: System.out.println("Paper");break;
  17. case scissors: System.out.println("Scissors");break;
  18. }//end switch
  19.  
  20. System.out.print("Computer Throws: ");
  21. switch(compthrow){
  22. case rock: System.out.println("Rock");break;
  23. case paper: System.out.println("Paper");break;
  24. case scissors: System.out.println("Scissors");break;
  25. }//end switch
  26.  
  27. if (playerthrow == rock && compthrow ==rock){
  28. System.out.println("its a draw");
  29. }else{
  30. if (playerthrow ==rock && compthrow == paper){
  31. System.out.println("comp wins");
  32. }else{
  33. if (playerthrow ==rock && compthrow == scissors){
  34. System.out.println("you wins");
  35. }
  36. }
  37. }//end else if
  38.  
  39. if (playerthrow == paper && compthrow ==paper){
  40. System.out.println("its a draw");
  41. }else{
  42. if (playerthrow ==paper && compthrow == scissors){
  43. System.out.println("comp wins");
  44. }else{
  45. if (playerthrow ==paper && compthrow == rock){
  46. System.out.println("you wins");
  47. }
  48. }
  49. }//end else if
  50.  
  51. if (playerthrow == scissors && compthrow ==scissors){
  52. System.out.println("its a draw");
  53. }else{
  54. if (playerthrow ==scissors && compthrow == rock){
  55. System.out.println("comp wins");
  56. }else{
  57. if (playerthrow ==scissors && compthrow == paper){
  58. System.out.println("you wins");
  59. }
  60. }
  61. }//end else if
Advertisement
Add Comment
Please, Sign In to add comment