-
Notifications
You must be signed in to change notification settings - Fork 0
/
prob_10.java
40 lines (29 loc) · 920 Bytes
/
prob_10.java
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
33
34
35
36
37
38
39
40
import java.util.Scanner;
public class prob_10 {
public static void main(String[] args) {
// if even, divide by two; if odd, triple it and add one
Scanner scan = new Scanner(System.in);
int num_1 = 0;
int cord = 0;
System.out.println("Enter your integer : ");
int number = scan.nextInt();
for (int i = 0; i < number; i++) {
num_1 = number % (10);
number = number / (10);
System.out.println("num_1 : " + num_1);
System.out.println("number : " + number);
cord += num_1;
System.out.println(cord);
}
if (number % 2 != 0) {
cord += number;
System.out.println(cord);
}else{}
if (cord % 2 == 0) {
System.out.println("The sum is even.");
}else if (cord % 2 != 0) {
System.out.println("The sum is odd.");
}
scan.close();
}
}