Skip to content

Commit d548489

Browse files
authored
Create NITIKA.java
1 parent d68e0a3 commit d548489

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

Codeshef/NITIKA.java

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import java.util.Scanner;
2+
3+
class Codechef
4+
{
5+
public static void main (String[] args) throws java.lang.Exception
6+
{
7+
Scanner scan = new Scanner(System.in);
8+
int T;
9+
T = Integer.parseInt(scan.nextLine().toString());
10+
String name,ans="";
11+
int i=1;
12+
13+
14+
do{
15+
name = scan.nextLine();
16+
String ch;
17+
int spaces=0, spass=0, strpass=0;
18+
19+
for(int j=0;j<=(name.length()-1);j++){
20+
ch=name.substring(j,j+1);
21+
if(ch.equals(" ")){
22+
spaces++;
23+
}
24+
}
25+
26+
for(int j=0 ; j<=(name.length()-1) ; j++){
27+
ch=name.substring(j,j+1);
28+
29+
if(spaces==0){
30+
if(j==0)ans = ans +ch.toUpperCase();
31+
else ans = ans + ch.toLowerCase();
32+
}
33+
34+
else if(spaces==1){
35+
36+
if(j==0){
37+
ans = ans +ch.toUpperCase();
38+
ans = ans+". ";
39+
}
40+
41+
if(spass==1){
42+
43+
if(strpass!=0){
44+
ans = ans+ch.toLowerCase();
45+
}
46+
47+
if(strpass==0){
48+
ans = ans+ch.toUpperCase();
49+
strpass++;
50+
}
51+
52+
}
53+
54+
55+
if(ch.equals(" ")){
56+
spass=1;
57+
}
58+
59+
}
60+
61+
else if(spaces==2){
62+
if(j==0){
63+
ans = ans +ch.toUpperCase();
64+
ans = ans+". ";
65+
}
66+
67+
if(spass==1){
68+
69+
if(strpass==0){
70+
ans = ans +ch.toUpperCase();
71+
ans = ans+". ";
72+
strpass++;
73+
}
74+
75+
}
76+
77+
if(spass==2){
78+
if(strpass>1){
79+
ans = ans+ch.toLowerCase();
80+
}
81+
if(strpass==1){
82+
ans = ans+ch.toUpperCase();
83+
strpass++;
84+
}
85+
86+
}
87+
88+
if(ch.equals(" ")){
89+
spass++;
90+
}
91+
92+
}
93+
94+
}
95+
ans = ans+"\n";
96+
97+
i++;
98+
}
99+
while(i<=T);
100+
System.out.println(ans);
101+
}
102+
}

0 commit comments

Comments
 (0)