-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJLB7.java
More file actions
28 lines (25 loc) · 829 Bytes
/
Copy pathJLB7.java
File metadata and controls
28 lines (25 loc) · 829 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
package Assignment1;
import java.util.Arrays;
import java.util.Scanner;
public class JLB7 {
public static void main(String [] args){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int l = String.valueOf(n).length();
String [] s = Integer.toString(n).split("");
int [] arr = new int[l];
for (int i = 0; i < l; i++){
arr[i] = Integer.parseInt(s[i]);
}
Arrays.sort(arr);
System.out.print("Sorted number in non-increasing order : ");
int sum = 0;
for (int i: arr) {
System.out.print(i);
if (i % 2 == 0) sum += i;
}
System.out.println("\n Sum of even numbers : " + sum);
if (sum > 15) System.out.println("True");
else System.out.println("False");
}
}