This commit is contained in:
ldy
2026-03-01 23:18:55 -05:00
commit 67f753a5d1
3087 changed files with 218259 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Question3</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@@ -0,0 +1,35 @@
import java.util.Scanner;
public class TestPalindrome {
public static void main(String[] args) {
System.out.print("Enter a String: ");
Scanner in = new Scanner(System.in);
String inStr = in.nextLine(); // read string
String lowStr = inStr.toLowerCase(); // convert to lowercase
int fIdx = 0, bIdx = inStr.length() - 1; // forward & backward indexes
char fChar, bChar; // forward & backward characters
while(fIdx < bIdx) {
fChar = lowStr.charAt(fIdx);
bChar = lowStr.charAt(bIdx);
if(!Character.isLetter(fChar)) { //when it is not a letter, adjust index
fIdx++;
continue;
}
if(!Character.isLetter(bChar)) {
bIdx--;
continue;
}
if(fChar != bChar) {
System.out.println("\"" + inStr + "\" is not a palindrome");
return;
} else { // match, change index
fIdx++;
bIdx--;
}
}
System.out.println("\"" + inStr + "\" is a palindrome");
}
}