Untitled

 avatar
unknown
plain_text
a year ago
813 B
4
Indexable
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();
    }

}
Editor is loading...
Leave a Comment