Click here to Skip to main content
15,910,211 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello, in my main method I have multiple questions which should be answer with one letter, but if the user enters capital, the program should lowercase it. So in the code below I described my problem and I was wondering if I should name each letter or if I should do something else

What I have tried:

Java
char lowerCase='C'='U'='F'='D'='K'='P';
 lowerCase = toLowerCase(lowerCase);

This method transforms the letters into lowercase letters
Java
public static char toLowerCase(char lowerCase){
   if (lowerCase >= 'A' && lowerCase <= 'Z')
     {
       lowerCase = (char) (lowerCase + 32);
     }
    return (lowerCase);
Posted
Updated 14-Nov-20 3:49am
v2
Comments
Richard MacCutchan 14-Nov-20 4:27am    
"if I should do something else"
Yes, read the Java documentation for String and Character types.

1 solution

Um. You do realize ... Java - String toLowerCase() and toUpperCase() Methods[^] exist already?
 
Share this answer
 
Comments
CPallini 14-Nov-20 9:49am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900