Hello! Tell me by code, what can I redo or add?
The task:
Create a program that will check whether a five-letter word entered by a user is a palindrome (examples: “lump”, “rotor”). If a non-5 letter word is entered, then report an error. The program should normally process the word, even if it uses different case characters. For example, the words “Lump” or “ROTOR” should also be considered palindromes.
public class Test { public static void main(String args []){ Scanner sr = new Scanner(System.in); String s; System.out.print("Введите слово из 5 букв -> "); if(sr.hasNext()){ s = sr.next(); if(s.length()==5){ s.toLowerCase(); s.toUpperCase(); System.out.print(s); }else{System.out.println("!!!Ошибка_Ввода!!!");}} } }
Another such question: how to write the code, so that it is valid when entering a whole or a real number produced an error, since only string input should be used?