Advertisement
Omar_Natour

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

Oct 2nd, 2015
109
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.  * ojnatour0001@student.stcc.edu
  8.  */
  9.  
  10. import java.util.Scanner;
  11. import java.lang.Math;
  12.  
  13. public class Homework3 {
  14.     public static void main(String[] args) {
  15.  
  16.         Scanner input = new Scanner(System.in);
  17.  
  18.         System.out.print("Welcome to Rock, Paper, Siccors! Choose a number that represents your choice." + "\n"
  19.                 + "scissors (0), rock (1), paper(2): ");
  20.         int rps = input.nextInt();
  21.         input.close();
  22.  
  23.         int crps = (int)(Math.random() * 3);
  24.  
  25.         if (rps == 0) {
  26.             if (crps == 0)
  27.                 System.out.println("The computer is siccors. You are siccors too. It is a draw.");
  28.             else if (crps == 1)
  29.                 System.out.println("The computer is rock. You are siccors. You lost.");
  30.             else
  31.                 System.out.println("The computer is paper. You are siccors. You won.");
  32.         } else if (rps == 1) {
  33.             if (crps == 0)
  34.                 System.out.println("The computer is siccors. You are rock. You won.");
  35.             else if (crps == 1)
  36.                 System.out.println("The computer is rock. You are rock. It is a draw.");
  37.             else
  38.                 System.out.println("The computer is paper. You are rock. You lost.");
  39.         } else if (rps == 2) {
  40.             if (crps == 0)
  41.                 System.out.println("The computer is siccors. You are paper. You lost.");
  42.             else if (crps == 1)
  43.                 System.out.println("The computer is rock. You are paper. You won.");
  44.             else
  45.                 System.out.println("The computer is paper. You are paper. It is a draw.");
  46.         } else
  47.             System.out.println("You have entered an invalid choice.");
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement