Computer Science, asked by srijana1429, 11 months ago

Write a java program which accepts a number from user. If the number is not a prime number then raise an exception ‘‘NoNotPrimeException’’. Otherwise display result.

Answers

Answered by sunidhi2295
0

import Java. until. *;

public class prime

{

public static void main(String args[ ])

{

int a;

Scanner sc = new scanner(System.in);

System.out.println("Enter any number");

a=sc.nextInt();

if(a%2==1)

System.out.println("The number is a prime number ");

else

System.out.println("The number is not a prime number ");

}

}

Hope that this will help you.

Similar questions