Loading...
Loading...
Loading...
Priya typed a whole paragraph with Caps Lock on by mistake. Read the line and swap the case of every letter: capital becomes small and small becomes capital. Digits, spaces and symbols stay the same. Use character arithmetic, not toUpperCase() on the whole line.
Example 1
Input
hELLO wORLD 2024
Output
Hello World 2024
Example 2
Input
mIxEd CaSe
Output
MiXeD cAsE
Try the problem first. Open one hint at a time.
A small letter is between 'a' and 'z'; a capital one is between 'A' and 'Z'.
Small and capital forms are always the same distance apart: ch - 'a' + 'A' turns a small letter into its capital.
The arithmetic gives an int, so cast it back with (char).
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor