Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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:

image text in transcribed

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 29

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions