Hot Student Stories

WAP to initialize a character and print whether it is upper caselower case or special character without using logical operators?

Kristi Hammond

in Schools

1 answer
1 view

1 answer

Whitney Matthews on August 21, 2019

The general solution to this problem is very simple to put on, but part of it is based on what a "special character" is. The part of code that handles this will be highlighted for the reader to implement as he/she. void displayType(char c) { . if(Character.isUpperCase(c)) { // top of the System box.out.println("uppercase"); . }else if(Character.isLowerCase(c)) { // lower case System.out.println("lowercase");. } else { // special case // here is where the "special character" part comes in. // Can be the definition of a "special character" as any non-letter character, // in case of that you can just put the line of print in this else // block. A "special character" may also be any non-letter, non-digit // character, so that it would be necessary to verify the Character.isDigit at // this point. . } .

Add you answer