-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevenoddsum.java
More file actions
29 lines (26 loc) · 783 Bytes
/
Copy pathevenoddsum.java
File metadata and controls
29 lines (26 loc) · 783 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
import java.util.Scanner;
public class evenoddsum {
public static void main(String arg[])
{
int n;
int oddsum=0;
int evensum=0;
Scanner sc= new Scanner(System.in);
int i;
do {
System.out.print("input a number: ");
n=sc.nextInt();
if (n%2==0) {
evensum+=n;
System.out.println("the evensum is :" + evensum);
}
else{
oddsum+=n;
System.out.println("the oddsum is :" + oddsum);
}
System.out.print("if you want to keep going press 1 else 0 :");
i=sc.nextInt();
} while (i==1);
sc.close();
}
}