Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Another question printing output

 
Troy Johnson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I just about have this program figured out. However, I am still having a problem getting the display to print out just right. I am pretty close. I am not sure how to add a text statemenet ("is safe") to true and ("is out") to false. Could anyone offer any suggestions or insight. Thanks again.
Here is how I am trying to get the display to look when the program runs:
Team 1 is up to bat:
Jason Crisp (average = 300.0) is out.
Rusty Johnson (average = 170.0) is safe.
Team 2 is up to bat:
Jason Harpham (average = 210.0) is safe.
Kevin McArthur (average = 375.0) is out.
Here is my code:

[ November 05, 2003: Message edited by: Troy Johnson ]
[ November 05, 2003: Message edited by: Troy Johnson ]
[ November 05, 2003: Message edited by: Troy Johnson ]
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't want to print out the retrun from isSafe. You want to use the return from isSafe in an "if" to determine what to print.
 
Tom Blough
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the ternary operator in Java. It's a condensed version of an if-else statement.
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is not a good example for someone learning java. Standard "if" statements are a better way for people starting out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic