-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoWhile.java
More file actions
33 lines (27 loc) · 846 Bytes
/
DoWhile.java
File metadata and controls
33 lines (27 loc) · 846 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
33
// AFG-DoWhile/DoWhile.java
import java.util.Scanner;
/*
Finding and printing digits of natural number
*/
// taha burak sahin pjatk
public class DoWhile {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while (true) {
System.out.print(
"\nEnter natural number (0 to exit) -> ");
int n = scan.nextInt();
if (n == 0) break;
System.out.print("Digits of " + n + ": |");
int numb = 1;
while (numb <= n/10) numb *= 10;
do {
int dig = n/numb;
n -= dig*numb;
numb /= 10;
System.out.print(" " + dig + " |");
} while (numb > 0);
System.out.println();
}
}
}