-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLOOP14.java
More file actions
32 lines (27 loc) · 939 Bytes
/
Copy pathLOOP14.java
File metadata and controls
32 lines (27 loc) · 939 Bytes
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
28
29
30
31
32
import java.util.Scanner;
public class LOOP14 {
//Write a program that reads a set of integers,
//andthen prints the sum of the even and odd integers.
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int numbers;
int choice;
int evenSum=0;
int oddSum =0;
do{
System.out.println("Enter the number :");
numbers=sc.nextInt();
if(numbers %2==0){
evenSum +=numbers;
}else{
oddSum +=numbers;
}
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 numbers: ");
System.out.println("Sum of odd numbers: ");
}
}
}