File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes please help! simple java program of rock paper scissors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "please help! simple java program of rock paper scissors" Watch "please help! simple java program of rock paper scissors" New topic
Author

please help! simple java program of rock paper scissors

alaina peeler
Greenhorn

Joined: Dec 04, 2005
Posts: 29
im writting a very easy program that plays rock, paper, scissors. The user plays against the computer as the computer generates a random number that represents rock, paper, or scissors. Everything is working ok except in the end im using nested if-else statements to compare the computer's play to the users and display who won and why.
Ex.
You choose rock. The computer chose scissors.
Rocks Crushes scissors. You win!

can somebody help me please ....instead of printing one statement it prints them all...
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

Well, show us your code, and we'll tell you what's wrong.


[Jess in Action][AskingGoodQuestions]
alaina peeler
Greenhorn

Joined: Dec 04, 2005
Posts: 29
ok here is my code....thanks for the help



EDIT by mw: Added Code Tags (and last 2 closing braces).
[ December 10, 2005: Message edited by: marc weber ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Problem: Your logic for determining the outcome is based only on userplay, without considering what the computer's choice is.

Suggestion: Move your outcome logic into the switch/case part of the code.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: please help! simple java program of rock paper scissors
 
Similar Threads
Scissors-rock-paper game looking for better way to write the program
i need help letting a user input anything all upercase, lowercase, or both.
Rock Paper Scissors
Which is your favorite Star Wars Episode?
generating unique Random Numbers