File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

please help! simple java program of rock paper scissors

 
alaina peeler
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, show us your code, and we'll tell you what's wrong.
 
alaina peeler
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic