-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSample2.java
More file actions
31 lines (22 loc) · 726 Bytes
/
Sample2.java
File metadata and controls
31 lines (22 loc) · 726 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
package Recursion;//sayý 3'e bölünebiliyormu programý:3'e bölünebilme kuralý sayý rakamlar toplamý 3'e bölünecektir
import java.util.Scanner;
public class Sample2 {
public static void main(String[] args) {
int number, total;
Scanner scan = new Scanner(System.in);
System.out.println("Enter a number:");
number = scan.nextInt();
total = SumOfDicits(number);
System.out.println("sum of dicits:" + total);
String DoÝtDivide=((total%3)==0)? "Dividing":"not dividing";
System.out.println("Is it divisible by 3? "+DoÝtDivide);
}
public static int SumOfDicits(int number) {
int result = 0;
while (number > 0) {
result = result + (number % 10);
number = number / 10;
}
return result;
}
}