Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: [METHOD] How: Count how many prime numbers there is between two numbers!

1. ## [METHOD] How: Count how many prime numbers there is between two numbers!

Hello!

I'm currently making a new program that will count how many prime numbers there is between two numbers (let's say 1 - 50).

I just wonder how do I make this method? Or do I need a for loop also?

This is how far I have become atm.. Please tell me if I have made something wrong.

OBS! There will also be a class with a main method which is not created yet.

```import java.util.Scanner;

class Prime
{
private int number1;
private int number2;

public Prime(int n1, int n2, int[] p1 ); {
System.out.print("Write in the first number:");
int under = s.nextInt();
System.out.print("Write in the second number:");
int over = s.nextInt();

this.number1 = n1;
this.number2 = n2;
}

public int getNumber1()
{
return this.Number1;
}

public void setNumber1()
{
this.number1 = n1;
}

public int getNumber2()
{
return this.Number2;
}

public void setNumber2()
{
this.number2 = n2;
}

public int getPrime()
{
}

}```

2. ## Re: [METHOD] How: Count how many prime numbers there is between two numbers!

/* If getting problem in understanding, let me know at my id saurabhmittal1987@gmail.com
Now you can add anything like menu to your code to use some unused methods like setNumber1 etc et
*/

Edited by moderator

3. ## Re: [METHOD] How: Count how many prime numbers there is between two numbers!

The Problems with Spoonfeeding

4. ## Re: [METHOD] How: Count how many prime numbers there is between two numbers!

hi dude this code will help you .. i just did it
...edited by moderator....

5. ## Re: [METHOD] How: Count how many prime numbers there is between two numbers!

Originally Posted by bojwess
hi dude this code will help you .. i just did it
...edited by moderator....
Evidently new contributors to the forums don't read the forum rules, or previous posts on the subject. bojwess, while we appreciate your participation I point you to the link I provided in my post above, and the forum rules post at the top of every forum. Your post has been edited