I'm taking my first Java class. I need to create a rock paper scissors game. I can't seem to figure out how to fix it. Please help! Thanks (:
I'm using NetBeans IDE 7.3 btw
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package rockpaperscissors;
/**
*
* @author Christina
*/
import java.util.Scanner;
public class Rockpaperscissors {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int Computer = 0, Player = 0, tie = 1, compic = 0, pscore = 0, tie = 0;
int end = 0;
Scanner scan = new Scanner(System.in);
while (end < 3) {
System.out.print("scissor(0), rock (1), paper(2): ");
pscore = scan.nextInt();
compic = (int)(Math.random()*2);
switch (pscore) {
case 0 :
if (compic == 0) {
System.out.println("The computer is scissor. You are scissor too. It is a draw.");
tie++;
}
else if (compic == 1) {
System.out.println("The computer is rock. You are scissor. Computer won.");
Computer++;
}
else
{
System.out.println("The computer is rock. You are paper. You won.");
Player++;
end++;
}
break;
case 1 :
if (compic == 0) {
System.out.println("The computer is scissor. You are rock. You won.");
Player++;
end++;
else if (compic == 1) {
System.out.println("The computer is rock. You are rock. It is a draw.");
tie++;
}
else
{
System.out.println("The computer is paper. You are rock. Computer won.");
Computer++;
}
break;
case 2 :
if (compic == 0) {
System.out.println("The computer is scissor. You are paper. Computer won.");
Computer++;
}
else if (compic == 1) {
System.out.println("The computer is rock. You are paper. You won.");
Player++;
}
else
{
System.out.println("The computer is paper. You are paper. It is a draw.");
tie++;
}
break;
default :
System.out.println("Error");
break;
}
}
System.out.println("");
System.out.println("The player wins : " + Player);
System.out.println("The computer wins : " + Computer);
System.out.println("Tie : " + tie);
}
}