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

• October 16th, 2011, 10:09 AM
Secret20
[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.

Code :

```import java.util.Scanner;   class Prime { private int number1; private int number2; private int[] primenumber1;   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; this.primenumber1 = p1; }   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() { return this.primenumber1; }       }```
• October 16th, 2011, 12:32 PM
Saurabh Mittal
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
• October 16th, 2011, 03:56 PM
copeg
Re: [METHOD] How: Count how many prime numbers there is between two numbers!

The Problems with Spoonfeeding
• October 18th, 2011, 01:01 PM
bojwess
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....
• October 18th, 2011, 02:30 PM
copeg
Re: [METHOD] How: Count how many prime numbers there is between two numbers!
Quote:

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