• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Assignment

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
System.out.println ( number5 + "is the greatest number" );
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic