aspose file tools*
The moose likes Java in General and the fly likes Assignment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Assignment" Watch "Assignment" New topic
Author

Assignment

Joe Soster
Greenhorn

Joined: Oct 24, 2005
Posts: 2
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

Joined: Aug 30, 2005
Posts: 13
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

Joined: Oct 24, 2005
Posts: 2
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

Joined: Jun 02, 2003
Posts: 1923

System.out.println ( number5 + "is the greatest number" );


http://home.arcor.de/hirnstrom/bewerbung
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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?


Java API Documentation
The Java Tutorial
 
Don't get me started about those stupid light bulbs.
 
subject: Assignment