Thursday, March 4, 2010

Palindrome

import java.util.*;
public class Palindrome
{
public static void main(String[] args)
{
String deLimiters = ";:'<>,./?-+!@#$%^&*() ";
Stack stack = new Stack();
Scanner reader = new Scanner(System.in);

while(true)
{
String palindrome = "";
String backwards = "";

System.out.println("Please enter a palindrome (Type n to quit): ");
String str = reader.nextLine();

if(str.equalsIgnoreCase("n"))
{
System.exit(0);
}
StringTokenizer tokens = new StringTokenizer(str, deLimiters);
StringTokenizer tokens2 = new StringTokenizer(palindrome, deLimiters);



while(tokens.hasMoreTokens())
{
palindrome += tokens.nextToken();
}
for(int i = 0; i < palindrome.length(); i++)
{
stack.add(palindrome.substring(i, i +1));
}

while(! stack.empty())
{
backwards += stack.pop();
}
if(palindrome.equalsIgnoreCase(backwards))
{
System.out.println("Your phrase: " + palindrome + " is a Palindrome");
}
else
{
System.out.println("Your phrase: " + palindrome + " is not a Palindrome");
}
}

}

}

OUTPUT
--------------------Configuration: --------------------
Please enter a palindrome (Type n to quit):
SAYA
Your phrase: SAYA is not a Palindrome
Please enter a palindrome (Type n to quit):
KAKAK
Your phrase: KAKAK is a Palindrome
Please enter a palindrome (Type n to quit):
N

Process completed.

1 comment:

  1. GREAT DEVELOPMENT GOALS ON ONLINE FUNDING ACCOUNTS. (3min read.)
    CRYPTOCURRENCY (BITCOIN) underhanded agency. The world's interesting array on financial change you wouldn't ever want to regret missing out on. Here is a global focus fully immersed to a degree that the subject in question Is an highly profitable finance worthwhile experience on merits. The organisation Constructing a long focus on funding your cryptocurrency(bitcoin) wallet with an enormous amounts of coins, including PAYPAL ACCOUNT, ONLINE BANK ACCOUNTS, ATM, and CREDIT CARD LOADING/CREDIT CARD DEPT CLEARANCE. Up a world of unimagined decentralized possibilities, where more online banking funds on value can be built, transferred, and managed with greater ease and transparency via Hacking.
    Being a victim of CRYPTOCURRENCY(bitcoin) Funds Mishap prompt our effort on finance cyber scandal focus (CSF). And the most interesting, Bitcoin Wallet Hack Rectification (BWHR), Bitcoin loading, PayPal loading, credit cards/ATM hack.
    Firstly,⚠warning!
    With money making, scam is a pretty common occurence today. Consumers have to be on a watch at any atrempt on financial fraud. That includes an ultimate addition of insult to injury. Be wary of forgeries who target victim of previous con, luring you in with bogus promises and you can even be charge for actions you could do on your own.
    This is a life time transformation with the professionals."
    You been trying so hard to meet with the real deal and changing your financial status to a massive ultimate crypto/dollar bill here is where your search ends. There is never a pleasure in been poor.
    As a strong and established personnel of cryptocurrency (bitcoin), PayPal, credit card user, in the terms of solid community, we strive to continue our mission on helping Individuals who are facing various cyber problems mostly the bitcoin hack swindles. Good news comes rare and it's left for us to whether cherish such glittering ounce of it like a priceless diamond or the otherwise.
    As part of our core mission and value to fix a dysfunctional bitcoin wallet accounts back to it normal stability and increasingly loading different accounts with huge funds via a dominant online crocked cyber tech algorithms. Taking a weighty focus on bitcoin hacks, For instance, wallet account facing problems which incudes.
    ▪Slack hacking bots,
    Fradulent bitcoin minning through brokers
    ▪Wallet hack,
    ▪Bitcoin minning pool and exchage hacking,
    ▪Changing wallet addresses
    ▪Cryptocurrency theft,
    ▪Freeze mining on crptocurrency.
    Here you are been given a chance to recover what you thought you lost and earnestly making a lot of funds via this highly classified information. This is a global information that navigates a newbie to a prominent encounter. We treat every request with patience and outmost confidence. Basically, hacking requires patience and no funds related successful hack goes lesser than 16 hours. The bottomline is we make a purposeful use of the time in lenience to attain a positive result to our clients.
    For our prominent services like Paypal funds loading, credit card dept clearance, credit card loading, website hack, social media hack, and one of the most important is loading up an empty online bank account with huge funds according to the account's capacity, you will all find your deepest longings to be reviewed. It's always like a dream.
     The job with the Globalhacks will be a sudden bursts of complete transformative joy and this is reality to your dreams.
    For more solid info and help,
    Contact:
    Cryptobase.hack(at)protonmail(.)com
    Globalhacktech(at)protonmail(.)com for proficient services.
    AndrewHay©️LLC 2019

    ReplyDelete