You are here: DEVPPL Forum Programming JavaScript Forum
NOTIFICATIONS
54.126
MEMBERS
15.697
TOPICS
62.285
POSTS
  562
FLASH GAMES
7.740
TUTORIALS
 

Login

E-mail:
Password:

Java based compiler giving me problems

0

Loading

Java based compiler giving me problems

Postby Sasukechaos » Wed Nov 15, 2006 12:21 pm

For some reson the buffered reader that im using

BufferedReader BR = new BufferedReader(new InputStreamReader (System.in));

isnt liked by "DoctorJava" Can anyone guess why? And in the meantime, is there anything else worng with this?

/*Joe Spike
*2nd period
* Palindrome
*Nov 9,06
*/

import java.io.*;

public class Palindrome
{
public static void main (String args[]) throws IOException
{

String str1, letterA, letterB;
int first, last;
double counter, lenght;

//Setup Buffered Reader
BufferedReader BR = new BufferedReader(new InputStreamReader (System.in));

//inputs
System.out.println("Input a Word. I'll check if its a palindrome, but please remove all the spaces from it if its a sentance ok?");
str1 = BR.readLine();

//Solve common User Error
str1.toLowerCase();

//Set variable values for use in loop
length = str1.length();
first=(-1);
last=length;

//Do loop to run through letters
do {
//incremented
first++;
last--;
//display letters to middle
letterA=(str1.substring(first,1));
letterB=(str1.substring(last,1));

//if statment to add to counter
if (str1.substring(first,1)==str1.substring(last,1)) {
counter++;
}
System.out.println (letterA + " " + letterB);
}
while ((first!=last) || (first<last));

//if all the letters to the middle or one over match and 1 is added to the counter for each that matches with one on the oposite side, then the counter would only be greater if each letter matched - a palindrome)
if (counter>(length/2)) {
System.out.println("Guess what! you gots a palindrome!");
}
Sasukechaos
 
Reputation: 0
Posts: 1
Joined: Wed Nov 15, 2006 12:17 pm
Highscores: 0
Arcade winning challenges: 0

Java based compiler giving me problems - Sponsored results

Sponsored results

Login to get rid of ads

 

^ Back to Top