[Shenji 6. Example 1] Automatic correction
Topic link: https://www.luogu.com.cn/problem/P5733
Title description
Everyone knows that some office software has the function of automatically converting letters to uppercase. Enter a string of no more than 100 and no spaces. All lowercase letters in the string are required to be converted to uppercase letters and output.
Input format
no
Output format
no
Sample input and output
Enter #1
Luogu4!
Output #1
LUOGU4!
Problem-solving ideas:
Lowercase letters are converted to uppercase letters, and uppercase letters are output as they are.
code show as below:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
char[] c = s.toCharArray();
for (int i = 0; i < c.length; i++) {
if (c[i] >= 'a' && c[i] <= 'z')
c[i] = (char) (c[i] - 32);
}
for (int i = 0; i < c.length; i++) {
System.out.print(c[i]);
}
}
}