-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSorted.java
More file actions
49 lines (39 loc) · 1.01 KB
/
Sorted.java
File metadata and controls
49 lines (39 loc) · 1.01 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.Scanner;
// DONE
public class Sorted
{
public static void main(String[] args) {
Scanner obj = new Scanner(System.in);
int [] a = new int[5];
System.out.println(" CHECKING FOR ASCENDING ORDER \n");
for (int i = 0; i < a.length; i++) // STORING
{
System.out.print(" Enter the " + (i+1) + " Number : ");
a[i] = obj.nextInt();
}
int j = 0; // manual gear shifting
boolean check = false;
while (j < 4) // due to j+1
{
if (a[j] > a[j+1]) // checking for ascending order
{
check = false;
break;
}
else
{
check = true;
}
j++;
}
System.out.println(); // SPACING
if (!check) // check is false
{
System.out.println(" NOT SORTED! ");
}
else
{
System.out.println(" SORTED! ");
}
}
}