Page 1 of 1 |
farne
Posts: 3725
Location: Serbia
|
|
Back to top |
|
 |
|
Posted: Wed, 9th Nov 2011 22:40 Post subject: |
|
 |
Store numbers in array, sort it and output the content.
|
|
Back to top |
|
 |
garus
VIP Member
Posts: 34200
|
Posted: Wed, 9th Nov 2011 23:02 Post subject: |
|
 |
snip
Last edited by garus on Tue, 27th Aug 2024 21:36; edited 1 time in total
|
|
Back to top |
|
 |
|
Posted: Wed, 9th Nov 2011 23:24 Post subject: |
|
 |
That copypasta is very quality Indian code, very good if you are payed per byte
wizarD., with arrays it should be something like this
Code: | Integer[] numbers = new Integer[3];
numbers[0] = input.nextInt();
numbers[1] = input.nextInt();
numbers[2] = input.nextInt();
Arrays.sort(numbers);
System.out.println("numbers[] = " + Arrays.toString(numbers) ); |
|
|
Back to top |
|
 |
|
|
Back to top |
|
 |
|
Posted: Wed, 9th Nov 2011 23:35 Post subject: |
|
 |
I wanted to keep it as simple as possible as wizarD. is still in earliest stages of leaning Java 
|
|
Back to top |
|
 |
|
Posted: Wed, 9th Nov 2011 23:40 Post subject: |
|
 |
Hm... you don't think they already handled loops? 
|
|
Back to top |
|
 |
Werelds
Special Little Man
Posts: 15098
Location: 0100111001001100
|
|
Back to top |
|
 |
|
Posted: Thu, 10th Nov 2011 20:30 Post subject: |
|
 |
Quote: | import java.util.Scanner;
public class lowtohigh {
public static void main(String[] args) {
System.out.println("Enter the three numbers from lowest to highest: ");
Scanner input = new Scanner(System.in);
int unit1 = input.nextInt();
int unit2 = input.nextInt();
int unit3 = input.nextInt();
System.out.println(unit1 + " " + unit2 + " " + unit3);
}
}
|
Simple!
|
|
Back to top |
|
 |
|
Posted: Thu, 10th Nov 2011 20:48 Post subject: |
|
 |
@BearishSun: 
|
|
Back to top |
|
 |
garus
VIP Member
Posts: 34200
|
Posted: Thu, 10th Nov 2011 21:00 Post subject: |
|
 |
|
|
Back to top |
|
 |
Page 1 of 1 |
All times are GMT + 1 Hour |