Omar_Natour

Natour, O. 10/2/15 Csc-111-D01 Hw 3.17

Oct 2nd, 2015
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. /*
  2.  * Omar Natour
  3.  * 10/2/2015
  4.  * Csc-111-D01
  5.  * Problem: 3.17
  6.  * Play a game of rock paper scissors against the computer.
  7.  */
  8.  
  9. import java.util.Scanner;
  10. import java.lang.Math;
  11.  
  12. public class Homework3 {
  13.     public static void main(String[] args) {
  14.  
  15.         Scanner input = new Scanner(System.in);
  16.  
  17.         System.out.print("Welcome to Rock, Paper, Siccors! Choose a number that represents your choice." + "\n"
  18.                 + "scissors (0), rock (1), paper(2): ");
  19.         int rps = input.nextInt();
  20.         input.close();
  21.  
  22.         int crps = (int)(Math.random() * 3);
  23.  
  24.         if (rps == 0) {
  25.             if (crps == 0)
  26.                 System.out.println("The computer is siccors. You are siccors too. It is a draw.");
  27.             else if (crps == 1)
  28.                 System.out.println("The computer is rock. You are siccors. You lost.");
  29.             else
  30.                 System.out.println("The computer is paper. You are siccors. You won.");
  31.         } else if (rps == 1) {
  32.             if (crps == 0)
  33.                 System.out.println("The computer is siccors. You are rock. You won.");
  34.             else if (crps == 1)
  35.                 System.out.println("The computer is rock. You are rock. It is a draw.");
  36.             else
  37.                 System.out.println("The computer is paper. You are rock. You lost.");
  38.         } else if (rps == 2) {
  39.             if (crps == 0)
  40.                 System.out.println("The computer is siccors. You are paper. You lost.");
  41.             else if (crps == 1)
  42.                 System.out.println("The computer is rock. You are paper. You won.");
  43.             else
  44.                 System.out.println("The computer is paper. You are paper. It is a draw.");
  45.         } else
  46.             System.out.println("You have entered an invalid choice.");
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment