Flash Games

 FAQ   Search   Members   Groups   Register  User Control Panel      Login 

Your time now:
Mon Nov 23, 2009 10:45 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ]  Bookmark and Share
Author Message
 Post subject: Java based compiler giving me problems
PostPosted: Wed Nov 15, 2006 12:21 pm 
Offline

Joined: Wed Nov 15, 2006 12:17 pm
Posts: 0
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!");
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group - Flash Games - TNX Invitation Code - TNX Review


Webmaster - Excruciating - Johnathan - Kotik - Ash - Tomi - rangana - Phate - dflynn - Medley