Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch.claude_martin;
- import java.util.Scanner;
- public class SomeClass {
- public static void main(String args[]) throws ClassNotFoundException {
- try (var kb = new Scanner(System.in)) {
- while (true) {
- System.out.println("input a word and hit enter (type 'exit' to exit)");
- var word = kb.nextLine();
- if ("exit".equals(word))
- break;
- var word2 = new StringBuffer(word).reverse().toString();
- if (word.equals(word2))
- System.out.format("The word '%s' is a palindrome%n", word);
- else
- System.out.format("The reverse of '%s' is '%s'%n", word, word2);
- }
- System.out.println("good bye");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement