Menentukan Palindrome

Judul : Menentukan Algoritma Palindrome

Deskripsi :
a.Input satu buah kata
b.Inisialisasi string
c.Tampilkan kata yang sudah diinput oleh user
d.Simpan sementara kata tersebut di dalam StringBuffer
e.if((sb.toString()).equals((sb.reverse()).toString()))
f.Jika hasil Palindrome, maka tampilkan “Yes!!! Ini palindrome”
g.Jika tidak, maka tampilkan “ini bukan Palindrome

Program dalam java :

import java.io.*;
public class Tugas1 {
public static void main(String [] args) throws IOException
{
StringBuffer sb;
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Input satu kata: ");
String s1 = input.readLine();
sb = new StringBuffer(s1);
if((sb.toString()).equals((sb.reverse()).toString()))
{
System.out.println("Yes!!! ini palindrome");
}
else
System.out.println("ini bukan palindrome");
}

About Sheilla Rizkia Ferianty

Semangat!

Posted on 01/12/2011, in Java. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: