package com.codegym.task.task08.task0823;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Going national
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s = reader.readLine();
char[] m = s.toCharArray();
int size = m.length;
m[0] = (char) (m[0] - 32);
int i = 1;
while (i != size)
{
if(m[i] == ' ')
{
m[i + 1] = (char) (m[i + 1] - 32);
}
i++;
}
//System.out.println(s);
System.out.println(m);
}
}
Problem with last test requirement
Archived
Comments (6)
- Popular
- New
- Old
You must be signed in to leave a comment
Dmitriy Bursa
14 July 2019, 17:18
try to solve through
String.split, String.toUpperCase , String.substring
0
MBC
14 July 2019, 17:22
Is there a way to do it where I can split the string after reading it into variable s and then, convert it into a char array?
0
Dmitriy Bursa
14 July 2019, 17:24
first step
next: get 1st symbol, to uppercase it, make string (use substring)
in the loop
+2
Dusernajder
15 July 2019, 09:09
What are the names of these kinds of arguments? How can I search it up? (\\s+)
0
Dmitriy Bursa
15 July 2019, 18:20
it's a regular expression
look this (note this: 4. Using regular expressions with String methods)
https://www.vogella.com/tutorials/JavaRegularExpressions/article.html
s.split("regex") in the table, regex-value is \\s+
and this
https://codegym.cc/groups/posts/regex-java
+2
Dusernajder
18 July 2019, 06:57
Thank you indeed.
0