Hey guyz i'm a newbie in java and I would like to create a program to find all palindrome prime numbers between two integers supplied as input (start and end points are excluded). I've started but now i'm stuck... Can u help me???

import java.util.*;
class Question4{
    public static void primeNumber (int limit){


    Scanner user = new Scanner (System.in);

    int x;
    int y;
    int div=2;
    int count=0;

    System.out.println ("Enter the starting point N:");
      x = user.nextInt();
    System.out.println ("Enter the ending point M:");
      y = user.nextInt();
    while (count>x && count<y){
        for (i=0;i>x;i++)
    }
  }
}

Recommended Answers

All 4 Replies

You will never get inside the while loop because you set count=0 and you don't know what x or y will be. Since you are setting x to be you starting number try this:

int x;
int y;
int div=2;
int count=0;

System.out.println ("Enter the starting point N:");
x = user.nextInt();
System.out.println ("Enter the ending point M:");
y = user.nextInt();

[B]count=x+1;[/B]

while (count<y){
//your code here

//in the end:
count++;
}

or try this:

for (int i=x+1;i<y;i++) {

}

By the way what kind of algorithm will you use?

hey javaAddict, the thing is that i dnt knw what code to type after the while loop :(

Then you have a bit of studying to do, because that is the heart of the homework assignment. If you need help with homework, you'll need to get a little further than this on your own.

thank's anyway guyz :( let get in the book ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.