Question
Can I get help on i mplementing the program below into a JFrame ? This is for Java. Copied Code: import java.util.Scanner; public class Lab6
Can I get help on implementing the program below into a JFrame? This is for Java.
Copied Code:
import java.util.Scanner;
public class Lab6 {
public static void main(String[] args) {
Scanner inScanner = new Scanner(System.in);
System.out.println("Enter a string: ");
String text = inScanner.nextLine();
if (isPolindrome(text)) {
System.out.println(text + " is polindrome ");
} else {
System.out.println(text + " is not polindrome ");
}
}
private static boolean isPolindrome(String str) {
str = str.toUpperCase();
str = str.replaceAll("[^A-Za-z]", "");
if (str.length() == 0 || str.length() == 1)
return true;// if length =0 OR 1 then it is
else if (str.charAt(0) == str.charAt(str.length() - 1))
return isPolindrome(str.substring(1, str.length() - 1));
return false;
}
}
The Question for this code was:
Again, I need the code to be implemented into a JFrame.
Thank you for trying to help me!
1 import java util. Scanner 3 public class Lab6 1 5e public static void main Strin DJ args 1 Scanner Scanner new Scanner System. in in System. out.printlnC"Enter a string: String text in Scanner next Line t if Cis Polindrome text System. out.printlndtext is polindrome 10 else 11 System. out.printlnCtext is not polindrome 12 13 14 15 16 17e private static boolean isPolindrome String str 18 str str. Case C) .toUpper 19 20 str str replaceAllC" CAA-Za-z] if (str. LengthC) l I str length G) 2- 1) 21 22 return true; if length OR 1 then it is else if (str char 0) str char str length() 1)) 23 24 return is Polindrome str. substring C1, str. lengthC) 1)); return false; 25 26 28 29Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started