Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Assignment2 {
  4.  
  5. public static void main(String[] args) {
  6.  
  7.  
  8. Scanner scan = new Scanner(System.in);
  9. String rock = "";
  10. String paper = "";
  11. String scissors = "";
  12. String player1 = "";
  13. String player2 = "";
  14.  
  15. System.out.println("Choose rock, scissors, or paper");
  16. player1 = scan.nextLine();
  17.  
  18. System.out.println("Choose rock, scissors, or paper");
  19. player2 = scan.nextLine();
  20.  
  21. if(player1.equals(player2))
  22. {
  23. System.out.println("It's a tie!");
  24.  
  25. } else {
  26. if (player1.equals("rock")) {
  27. if (player2.equals("scissors"))
  28. {
  29. System.out.println("Player 1 wins");
  30. }
  31. } else {
  32. if (player1.equals("paper")) {
  33. if (player2.equals("rock"))
  34. {
  35. System.out.println("Player 1 wins");
  36. }
  37. } else {
  38. if (player1.equals("scissors")) {
  39. if (player2.equals("paper"))
  40. {
  41. System.out.println("Player 1 wins");
  42. }
  43.  
  44. if (player1.equals("paper")) {
  45. if (player2.equals("scissors"))
  46. {
  47. System.out.println("Player 2 wins");
  48. }
  49. } else {
  50. if (player1.equals("rock")) {
  51. if (player2.equals("paper"))
  52. {
  53. System.out.println("Player 2 wins");
  54. }
  55. } else {
  56. if (player1.equals("scissors")) {
  57. if (player2.equals("rock"))
  58. {
  59. System.out.println("Player 2 wins");
  60. }
  61. }
  62.  
  63. }
  64. }
  65. }
  66. }
  67. }
  68. }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement