-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModified.java
More file actions
52 lines (50 loc) · 1.08 KB
/
Modified.java
File metadata and controls
52 lines (50 loc) · 1.08 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
51
52
import java.util.*;
public class Modified
{
String s1,s2;
Modified()
{
s1="";
s2="";
}
void Input()
{
Scanner as=new Scanner(System.in);
System.out.print("Enter the Sentence:");
s1=as.nextLine();
}
void Process()
{
s1=s1+" ";
int l,l2,i,k=0;
l=s1.length();
char c;
String s="";
for(i=0;i<l;i++)
{
c=s1.charAt(i);
if(c==' ')
{
s=s1.substring(k,i);
l2=s.length();
if(l2%2==0)
s2+=s.substring(((l2/2)-1),((l2/2)+1))+" ";
else
s2+=s.charAt(l2/2)+" ";
k=i+1;
}
}
}
void Display()
{
System.out.println("The New Modiefied Sentence:"+s2);
}
public static void main(String[] args)
{
System.out.println("\tMid-Letter Extractor\n");
Modified as1=new Modified();
as1.Input();
as1.Process();
as1.Display();
}
}