simongonzalez6927 simongonzalez6927
  • 27-08-2018
  • Computers and Technology
contestada

Write java program method that takes input as non negative integers and return the number of palindrome or not a palindrome

Respuesta :

tonb
tonb tonb
  • 27-08-2018

Will this help you? Not sure if you ask that your program can take multiple numbers and test each for palindrome, but surely you will need a function like below:


public static boolean isPalindrome(int n) {

String s = Integer.toString(n);

for(int i=0; i<s.length()/2; i++) {

if (s.charAt(i) != s.charAt(s.length()-i-1)) {

return false;

}

}

return true;

}

Answer Link

Otras preguntas

Factor out the GCF 21x^3 + 24x^2 - 12x
why is light energy on the left side of the equation?
what is the Antonym for the word moist
Observations and measurements recorded during an experiment. A. Ion B. Data C. Fat D. Atom
What can be inferred from these lines describing the pardoner in Chaucer's prologue to The Canterbury Tales? He had a fine veronica sewed to cap. His wallet lay
Mr. Arnold's 5th grade science class did an experiment to see if mold would grow better on moist bread or on dry bread. Each lab group was given two pieces of b
AP US History question: “Vice-presidents who have succeeded to the presidency on the death of the President have been less effective in their conduct of domesti
Which of the following are typically favored by conservatives? -relying on private organizations and individuals to help those in need -regulating business and
the line equation that goes through (3,4) and perpendicular to y=-2
[tex] 32^{ \frac{6}{5} } [/tex]