Question

write a program that prints all palindromic numbers between 0-9999 into the screen. Note :The code...

write a program that prints all palindromic numbers between 0-9999 into the screen.
Note :The code should be written in java language.

Homework Answers

Answer #1

import java.util.*;

public class Main {
public static void main(String[] args) throws Exception {
// Your code here!
  
for(int i=0;i<1000;i++){
if(i>0){
if(palindrome (i)){
System.out.println(i);
}
}
else{
System.out.println(i);
}

  
}
  

}
public static boolean palindrome (int n){
int temp=n,sum=0;   
while(n>0){   
int r=n%10;
sum=(sum*10)+r;   
n=n/10;   
}   
if(temp==sum){
return true;
}
return false;
}
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Using for loops: - write a Java program that adds numbers between 1 to 100 and...
Using for loops: - write a Java program that adds numbers between 1 to 100 and prints the result. - write a Java program that adds odd numbers between 1 to 100 and prints the result - write a Java program that averages even numbers between 5 to 30 and prints the result
- Write a python program which prints all the numbers between 1 and 100 that are...
- Write a python program which prints all the numbers between 1 and 100 that are divisible by 3.
Write a program with while loop that prints all numbers between 5 and 100 (inclusive) that...
Write a program with while loop that prints all numbers between 5 and 100 (inclusive) that are divisible by 5.
Write a program that finds and prints all of the prime numbers between 3 and X...
Write a program that finds and prints all of the prime numbers between 3 and X (X is input from the user). A prime number is a number such that 1 and itself are the only numbers that evenly divide it (for example, 3, 5, 7, 11, 13, 17, …). One way to solve this problem is to use a doubly nested loop (a loop inside another loop). The outer loop can iterate from 3 to N while the inner...
Java Write a program that prints the letters corresponding to the numbers on the telephone. So...
Java Write a program that prints the letters corresponding to the numbers on the telephone. So if you were to enter 6 it should print MNO. Now since you do not know how to do a System.in just do you for the number 7. So your code should be like int numberEntered = 7; String value; swtich (numberEntered){ case 1: value = "Nothing definded for 1"; break; case 2 : value = "A,B,C"; break ..... ..... default: value = "Not...
Write a java program that prints the letters corresponding to the numbers on the telephone. So...
Write a java program that prints the letters corresponding to the numbers on the telephone. So if you were to enter 6 it should print MNO. Now since you do not know how to do a System.in just do you for the number 7. So your code should be like int numberEntered = 7; String value; swtich (numberEntered){ case 1: value = "Nothing definded for 1"; break; case 2 : value = "A,B,C"; break ..... ..... default: value = "Not...
PYTHON 3 Write a program that prints the count of all prime numbers between A and...
PYTHON 3 Write a program that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows: A = 21212 B = A + 5000 Just a recap on prime numbers: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2, 5, 7, 11, 13, 17, 19, 23, and 29. Rules: You should first...
Write a program in JAVA that prints the bounds ( maximum and minimum values) for all...
Write a program in JAVA that prints the bounds ( maximum and minimum values) for all integer data types in Java.
Please code C# 7. Write a program that can calculate the sum of all numbers between...
Please code C# 7. Write a program that can calculate the sum of all numbers between 1 and 1000 inclusive (including 1 and 1000)
Write an assembly language program that prints your full name on the screen. Use .ASII pseudo-op...
Write an assembly language program that prints your full name on the screen. Use .ASII pseudo-op to store the characters at the top of your program Use BR to branch around the characters and use STRO to output your name. Comment each line except STOP and .END. Cut and paste the Assembler Listing into your document Paste a screen shot of the Output area of the Pep8 program Please use the name "Levin Fi" Assembler Listing Screen Shot of the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT