-
Notifications
You must be signed in to change notification settings - Fork 0
/
upperletter16(1).java
47 lines (38 loc) · 1.09 KB
/
upperletter16(1).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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class UpperLetter
{
public static void main(String args[])throws IOException
{
System.out.println("input");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
String s = "";
int flag=0;
if(Character.isLowerCase(str.charAt(0))==true)
s=s+(char)(str.charAt(0)-32);
else
s=s+(char)(str.charAt(0));
for(int i=1;i<str.length();i++)
{
if(Character.isLowerCase(str.charAt(i))==true)
{
char c=(char)(str.charAt(i-1));
if(c==' ')
{
char ch= (char)(str.charAt(i)-32);
s = s + ch;
flag=1;
}
}
if(flag==0)
{
s = s + str.charAt(i);
}
flag=0;
}
System.out.println("Output:");
System.out.println(s);
}
}