Home / Pemrograman / JAVA / Palindrome Words Java Algorithm And Source Code

Palindrome Words Java Algorithm And Source Code

Palindrome Words Java

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package menentukanpolindrom;

/**
*
* @author eko rudiawan
*/
import java.io.*;

public class MenentukanPolindrom {

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
BufferedReader dataInput = new BufferedReader(new InputStreamReader(System.in));
String input1;
char kata1[];
int panjangString;
boolean polindrom;
System.out.println("Program Menentukan Polindrom");
System.out.print("Masukkan Kata = ");
input1 = dataInput.readLine();
panjangString = input1.length();
input1 = input1.toLowerCase();
kata1 = input1.toCharArray();
int j = panjangString - 1;
polindrom = true;
for (int i = 0; i < panjangString / 2; i++) {
if (kata1[i] != kata1[j]) {
polindrom = false;
}
j--;
}
if (polindrom) {
System.out.println("POLINDROM");
} else {
System.out.println("TIDAK POLINDROM");
}
}
}

Tampilan Program

Palindrom Words Java
Palindrome Words Java

 

About Eko Rudiawan

Seorang lelaki yang punya ketertarikan dengan dunia elektronika dan robot yang saat ini sedang serius belajar tentang dunia bisnis dan internet marketing. My dream to be success technopreneur

Check Also

Searching Algoritm Java

Algoritma Searching Data Menggunakan Bahasa Java

Algoritma Searching Data /* * To change this template, choose Tools | Templates * and …

Leave a Reply

Your email address will not be published. Required fields are marked *

19 − thirteen =