-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumToWord_conv.java
More file actions
50 lines (49 loc) · 1.47 KB
/
NumToWord_conv.java
File metadata and controls
50 lines (49 loc) · 1.47 KB
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
import java.util.Scanner;
public class NumToWord_conv {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number to convert it to word:- ");
String Num = sc.nextLine();
int i=0;
while(i<=Num.length()-1){
char digit = Num.charAt(i);
switch(digit){
case'0':
System.out.print("Zero ");
break;
case'1':
System.out.print("One ");
break;
case'2':
System.out.print("Two ");
break;
case'3':
System.out.print("Three ");
break;
case'4':
System.out.print("Four ");
break;
case'5':
System.out.print("Five ");
break;
case'6':
System.out.print("Six ");
break;
case'7':
System.out.print("Seven ");
break;
case'8':
System.out.print("Eight ");
break;
case'9':
System.out.print("Nine ");
break;
default:
System.out.println("Please do not enter a number less than 0 or a floating number.");
i=Num.length()-1;
}
i++;
}
sc.close();
}
}