-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumStr.java
More file actions
56 lines (55 loc) · 953 Bytes
/
NumStr.java
File metadata and controls
56 lines (55 loc) · 953 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// This program will convert a number into word
import java.util.Scanner;
class NumStr
{
public static void main(String[] args)
{
Scanner s1 = new Scanner(System.in);
int num = s1.nextInt();
while(num>0)
{
int digit = num%10;
if (digit == 0)
{
System.out.print("Zero ");
}
else if (digit == 1)
{
System.out.print("One ");
}
else if (digit == 2)
{
System.out.print("Two ");
}
else if (digit == 3)
{
System.out.print("Three ");
}
else if (digit == 4)
{
System.out.print("Four ");
}
else if (digit == 5)
{
System.out.print("Five ");
}
else if (digit == 6)
{
System.out.print("Six ");
}
else if (digit == 7)
{
System.out.print("Seven ");
}
else if (digit == 8)
{
System.out.print("Eight ");
}
else
{
System.out.print("Nine ");
}
num =num/10;
}
}
}