# Beginner Help

• February 6th, 2013, 09:03 PM
Hawks
Beginner Help
Hey guys this is my first post. I am fairly new to Java and it would be much appreciated if I could get some help.

I am trying to solve this homework problem.
Game: scissor, rock, paper) Write a program that plays the popular scissor-rock- paper game. (A scissor can cut a paper, a rock can knock a scissor, and a paper can wrap a rock.) The program randomly generates a number 0, 1, or 2 representing scissor, rock, and paper. The program prompts the user to enter a number 0, 1, or 2 and displays a message indicating whether the user or the computer wins, loses, or draws.

This is what I currently have and I am stuck here. Anything would be helpful!

Code :

```//Create a Scanner for Input Scanner input = new Scanner(System.in);   //Pick a scissor (0), rock (1), paper (2) System.out.print ("scissor (0), rock (1), paper (2): ");   //Pick aRandomNumber between 0 and 2 int aRandomNumber = (int) (Math.random() * 3);   //Determine if scissor (0), rock (1), paper (2) int result = aRandomNumber; String hand; if (result == 0) { hand = " scissor"; } else if (result == 1) { hand = " rock"; } else if (result == 2) { hand = " paper"; }     System.out.println("Enter scissor (0), rock (1), paper (2)" + aRandomNumber +);   //       } }```
• February 6th, 2013, 09:09 PM
Norm
Re: Beginner Help
Can you explain what problems you are having? What are you stuck on?

Have you worked out the steps the program must do to play this game? You need to have done that before trying to write any code.
• February 6th, 2013, 09:14 PM
Hawks
Re: Beginner Help
I am having a problem with the command asking me to pick a number (0-2). It always fails. Sorry if this is a bad explanation, I am new to Java.
• February 6th, 2013, 09:17 PM
Norm
Re: Beginner Help
Quote:

problem with the command asking me to pick a number (0-2). It always fails.
Please explain what "fails" means. If there is an error message, copy it and paste it here.

On windows: To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'

Paste here.
• February 6th, 2013, 09:24 PM
Hawks
Re: Beginner Help
This is in my command window as of right now.

Code :

``` //Create a Scanner for Input Scanner input = new Scanner(System.in);   //Pick aRandomNumber between 0 and 2 int computerNumber = (int) (Math.random() * 3);   //Pick a scissor (0), rock (1), paper (2) System.out.print ("scissor (0), rock (1), paper (2): ");   //Determine if scissor (0), rock (1), paper (2) int result = computerNumber; String hand; if (result == 0) { hand = " scissor"; } else if (result == 1) { hand = " rock"; } else if (result == 2) { hand = " paper"; }     System.out.println(" The computer is " + hand + "You are "       } }```

I get this message:

run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: <any>
scissor (0), rock (1), paper (2): at rockscissorspaper.java.RockScissorsPaperJava.main( RockScissorsPaperJava.java:43)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
• February 6th, 2013, 09:33 PM
Norm
Re: Beginner Help
What line is line 43? The IDE doesn't give good compiler error messages. If you'd use the javac command to compile the code the error messages would be much better.
Here is a sample:
Code :

```TestSorts.java:138: cannot find symbol symbol : variable var location: class TestSorts var = 2; ^```