Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

write a java program to determine the smallest and largest of two numbers

 
Bill Zelan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can someone help me to code this :
thanks

Using the "input stream reader" functions, write a java program to determine the smallest and largest of two numbers.

1. create some variables named number1, number2, smallest, and biggest (all numbers should be integers).
input the values of the variables number1 or number2 from the keyboard (using input stream reader).
2. print out the sentence "The larger number is " followed by the value that is larger (either the value of number1 or number2) - use the if statement to find out which variable holds the larger value.
3. print out the sentence "The smaller number is " followed by the value that is smaller (either the value of number1 or number2) - use the if statement to find out which variable holds the smaller value.
4. test your program by inputting different values for the variables number1 and number2.
 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Give a shot yourself first, then if you get stuck with coding post what you have so far.



Hunter.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic