-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sort.java
27 lines (26 loc) · 956 Bytes
/
Sort.java
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 Sort {
public static void main(String[] args) {
System.out.println("Enter the string: ");
Scanner scanner = new Scanner(System.in);
String input = scanner.next();
int sumOfEvenDigits=0;
Integer a[]=new Integer[input.length()];
for(int increment=0;increment<input.length();increment++){
a[increment]=input.charAt(increment)-48;
if(a[increment]%2==0){
sumOfEvenDigits+=a[increment];
}
}
Arrays.sort(a,Collections.reverseOrder());
System.out.print("Sorted number in non-increasing order :");
for(int increment=0;i<input.length();increment++){
System.out.print(a[increment]);
}
System.out.println("\n Sum of even numbers : " +sumOfEvenDigits);
if(k>15)
System.out.println("True");
else
System.out.println("False");
}
}