Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Omar Natour
- * 10/2/2015
- * Csc-111-D01
- * Problem: 3.17
- * Play a game of rock paper scissors against the computer.
- * ojnatour0001@student.stcc.edu
- */
- import java.util.Scanner;
- import java.lang.Math;
- public class Homework3 {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Welcome to Rock, Paper, Siccors! Choose a number that represents your choice." + "\n"
- + "scissors (0), rock (1), paper(2): ");
- int rps = input.nextInt();
- input.close();
- int crps = (int)(Math.random() * 3);
- if (rps == 0) {
- if (crps == 0)
- System.out.println("The computer is siccors. You are siccors too. It is a draw.");
- else if (crps == 1)
- System.out.println("The computer is rock. You are siccors. You lost.");
- else
- System.out.println("The computer is paper. You are siccors. You won.");
- } else if (rps == 1) {
- if (crps == 0)
- System.out.println("The computer is siccors. You are rock. You won.");
- else if (crps == 1)
- System.out.println("The computer is rock. You are rock. It is a draw.");
- else
- System.out.println("The computer is paper. You are rock. You lost.");
- } else if (rps == 2) {
- if (crps == 0)
- System.out.println("The computer is siccors. You are paper. You lost.");
- else if (crps == 1)
- System.out.println("The computer is rock. You are paper. You won.");
- else
- System.out.println("The computer is paper. You are paper. It is a draw.");
- } else
- System.out.println("You have entered an invalid choice.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement