Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class PrimeNumbers {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String input = scan.nextLine().replace(".", " ");
- String[] arr = input.split(" ");
- int maxNum = -1;
- int num = -1;
- boolean isNum = true;
- for (int i = 0; i < arr.length; i++) {
- try {
- num = Integer.parseInt(arr[i]);
- } catch (NumberFormatException e) {
- isNum = false;
- }
- if (isNum) {
- num = Integer.parseInt(arr[i]);
- }
- if (num % 2 == 0 && num > maxNum) {
- maxNum = num;
- }
- isNum = true;
- }
- if (maxNum != -1) {
- System.out.println(maxNum);
- } else {
- System.out.println("-1");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement