-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnameconv.java
More file actions
43 lines (36 loc) · 840 Bytes
/
nameconv.java
File metadata and controls
43 lines (36 loc) · 840 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
import java.util.Scanner;
import java.lang.*;
class nameconv
{
public static void main(String[] args) {
System.out.println("Enter the name\n");
Scanner scan = new Scanner(System.in);
String name = scan.nextLine();
String edit = name.toLowerCase();
int con[] = new int[100];
int ptr;
int tmp;
int i;
System.out.println("The entered name is "+name);
ptr = 0;
for(i=0;i<name.length();i++)
{
char ch = edit.charAt(i);
tmp=(int)ch;
tmp=tmp-96;
if((tmp>=10)&&(tmp<=26))
{
con[ptr] = tmp/10;
con[ptr+1] = tmp%10;
ptr+=2;
}
else if (tmp<10) {
con[ptr] = tmp;
ptr++;
}
}
System.out.println("The numeric array is being printed\n");
for(i=0;i<ptr;i++)
System.out.println(" "+con[i]);
}
}