Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Java based compiler giving me problems



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
sasukechaos



Joined: 15 Nov 2006
Posts: 1

PostPosted: Wed Nov 15, 2006 12:21 pm    Post subject: Java based compiler giving me problems Reply with quote

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!");
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap