-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrder.java
More file actions
27 lines (26 loc) · 879 Bytes
/
Order.java
File metadata and controls
27 lines (26 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.*;
public class Order{
public static void main(String[] args){
//Create scanner class
Scanner input = new Scanner(System.in);
//Ask the user to put in three numbers
System.out.println("Enter three numbers and seperate them with a space: ");
//retrieve all three numbers seperatly
double num1 = input.nextDouble();
double num2 = input.nextDouble();
double num3 = input.nextDouble();
//Call the method
displaySortedNumbers(num1, num2, num3);
input.close();
}
//Create method to sort
public static void displaySortedNumbers(double num1, double num2, double num3){
double[] numbers = {num1, num2, num3};
//Sort the numbers with an array
Arrays.sort(numbers);
System.out.println("Numbers in sorted order: ");
for (double num : numbers) {
System.out.println(num);
}
}
}