Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assignment

 
Joe Soster
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My teacher wants me to create a program using java that takes 5 numbers and prints the highest and smalles of those numbers. She has not taught us how to use the else keyword yet and she says the program can be done using the if keyword. Anyone got any ideas?
 
Deepak Kaimal
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but it might be better if you thought of the answer yourself by realising that else means the same as "if not"
 
Joe Soster
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok i think i got the else thing i just dont know how to use it i think this is the basics of it...
if ( number5 > number4 )
System.out.printf( number5 is the greatest number );

else ( number4 > number5 )
System.out.printf( number4 is the greatest number );

but i get 3 errors with a carrot thing right under the is and the () and i dont know what to do from there

Any other helpfull hints?
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.out.println ( number5 + "is the greatest number" );
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joe Soster:

but i get 3 errors with a carrot thing right under the is and the () and i dont know what to do from there

Any other helpfull hints?


What are the errors? And which lines are causing them? Please provide more details so that we can help.

p.s. Since you haven't been taught about else, perhaps there is a way to do this without it. Can you think of a way to do so?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic