-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise07_19.java
More file actions
37 lines (31 loc) · 1022 Bytes
/
Copy pathExercise07_19.java
File metadata and controls
37 lines (31 loc) · 1022 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
28
29
30
31
32
33
34
35
36
37
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author jorda
*/
public class Exercise07_19 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the list size: ");
int[] list = new int[input.nextInt()];
System.out.print("Enter the contents of the list: ");
for (int i = 0; i < list.length; i++) {
list[i] = input.nextInt();
}
//read the list back to the user
System.out.println("The list has " + list.length + " integers ");
}
//determines if the list in in NON-DECREASING order
public static boolean isSorted(int[] array){
for (int i = 0; i < array.length-1; i++) {
if(array[i]>array[i+1])
return false;
}
return true;
}
}