Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- char[] numbers = scanner.nextLine().toCharArray();
- int evenSum = 0;
- int oddSum = 0;
- for (char digit : numbers) {
- int num = Integer.parseInt(String.valueOf(digit));
- if (num % 2 == 0) {
- evenSum += num;
- } else {
- oddSum += num;
- }
- }
- if (evenSum > oddSum) {
- System.out.println(evenSum + " energy drinks");
- } else if (evenSum < oddSum) {
- System.out.println(oddSum + " cups of coffee");
- } else {
- System.out.println(evenSum + " of both");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement