Untitled

mail@pastecode.io avatar
unknown
plain_text
22 days ago
813 B
2
Indexable
Never
import java.util.*;

public class Solution {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        int choice;
        int evenSum = 0;
        int oddSum = 0;

        do {
            System.out.print("Enter the number: ");
            int number = sc.nextInt();

            if (number % 2 == 0) {
                evenSum += number;
            }

            else {
                oddSum += number;
            }

            System.out.println("Do you want to continue ? Press 1 for yes or 0 for no");

            choice = sc.nextInt();

        } while (choice == 1);

        System.out.println("sum of even integers : " + evenSum);
        System.out.println("sum of odd integers : " + oddSum);

        sc.close();
    }

}
Leave a Comment