Java codes

5 pts.
Tags:
Java
Java programming
How to create a program in java that will display a lowest and highest number?
ASKED: March 16, 2009  2:32 PM
UPDATED: September 3, 2011  3:53 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Thers an alternate way to do this would be to store all those numbers into an array, then sort the array and gets the first and last element(It uses java.util package):

arr_nums // integer array of 100 numbers
java.util.Arrays.sort(arr_nums);
System.out.println(“The lowest number is ” + arr_nums[0]);
System.out.println(“The biggest number is ” + arr_nums[arr_nums.length-1]);

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    You should try to solve it by yourself. If you are not able to do it or you have some specific doubt/problem, post what you have done so far, and we will try to help you.
    65,110 pointsBadges:
    report
  • shiva3322
    first sort the array list and get the first element as smallest and the last element in the array is greatest number which is in java.util package of class Arrays.sort(arr_nums); System.out.println("The lowest number is " + arr_nums[0]); System.out.println("The biggest number is " + arr_nums[arr_nums.length-1]);
    660 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following