• Non ci sono risultati.

System.out.println("Write the word to check: &#34

N/A
N/A
Protected

Academic year: 2021

Condividi "System.out.println("Write the word to check: &#34"

Copied!
1
0
0

Testo completo

(1)

import java.io.*;

/** 21 Settembre 2013

* Write a description of class Palindromo here.

* A palindrome is a word or sentence that reads the same forward as it does backward.

* This program checks out if an input string is a palindrome.

Test it with - aveva - radar - ingegni - onorarono - aia

- ala - non - Anna - otto - oro - inni - afa - ossesso

* @author (your name)

* @version (a version number or a date) */

public class Palindrome {

public static void main (String args[]) throws Exception{

BufferedReader tastiera = new BufferedReader(new InputStreamReader(System.in));

System.out.println("Write the word to check: ");

String word=tastiera.readLine();

int lword=word.length();

int mword=(lword/2);

boolean flag=false; //false=palindrome - true=not palindrome

for(int i=0; i<=mword-1; i++){

if(!(word.charAt(i)==word.charAt(lword-i-1))) flag=true;

}

if(flag==true)

System.out.println("NOT PALINDROME");

else

System.out.println("PALINDROME");

} }

Riferimenti

Documenti correlati

Oct 23rd 2015, 9:57 by LAURA GARDINER | THE RESOLUTION FOUNDATION YOU often hear that the traditional employee

1 imental for the rights and welfare of migrants and communities across th 2 y increase the suffering and risks of migrants and refugees but will not di 3 tain

This study showed a lower risk of SSI, even though not statistically significant, in surgical procedures performed in unidirectional operating theatres (U-OTs) with

Without loss of generality we may assume that A, B, C are complex numbers along the unit circle. |z|

This part of the report focuses on the relationship between dynamic and productive &#34;territories&#34;, as contexts of reception of the development process, by identifying

Write a Prolog program to check if two not ordered input vectors contain the same elements.. Write a Prolog program which checks if two lists of integer values are

“decadent.” The Platonists see it has having no ruling principle, no cen- ter, no structure. The positivists see it as having no respect for hard fact, for that area

Use the word given in brackets to form a word that fits grammatically in the gap. They all stood up to the NATIONAL anthem, waving their country’s flag. Looking for work is