Question: **** The following in JAVA**** Find Prime Numbers Given an integer, find whether the numbers is a Prime number or not. Write a function: int

**** The following in JAVA****

Find Prime Numbers

Given an integer, find whether the numbers is a Prime number or not.

Write a function: int isPrime(int number) that accepts an integer number.

The isPrime function returns 1 if number is prime else 0.

Input: 11

Output: 1

EX: 11 can be divided exactly by 1 and 11. Hence it's a prime number.

Assume that, number is integer within the range [ 2,147,483,64 to 2,147,483,64 ].

****USE THE FOLLOWING DRIVER ***

* Do not modify the driver, just make a new class and method that function with the provided driver

public class DriverMain {

public static void main(String args[]){

Scanner s = new Scanner(System.in);

int n = s.nextInt();

HW2_P1 hw2p1 = new HW2_P1();

System.out.print(hw2p1.isPrime(n));

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!