-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprog11.java
51 lines (40 loc) · 950 Bytes
/
prog11.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
41
42
43
44
45
46
47
48
49
//11. program that searches for ssingle digit numbers in a text and changes them totheir corressponding words
package chap3;
import java.util.Scanner;
public class prog11
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
String s1="";
System.out.println("Enter a String");
String s=sc.nextLine();
for(int i=0;i<s.length();i++)
{
char ch=s.charAt(i);
if(ch=='0')
s1=s1+"zero";
else if(ch=='1')
s1=s1+"one";
else if(ch=='2')
s1=s1+"two";
else if(ch=='3')
s1=s1+"three";
else if(ch=='4')
s1=s1+"four";
else if(ch=='5')
s1=s1+"five";
else if(ch=='6')
s1=s1+"six";
else if(ch=='7')
s1=s1+"seven";
else if(ch=='8')
s1=s1+"eight";
else if(ch=='9')
s1=s1+"nine";
else
s1=s1+ch;
}
System.out.print(s1);
}
}