Free help with homework

Why join Brainly?

  • ask questions about your assignment
  • get answers with explanations
  • find similar questions


Import java.io.*;class prime{    public void check(int n)    {        int a=0;        for(int i=2;i<=n/2;i++)        {            int r=(n%i);            switch(r)            {                case 0:                a=1;                break;                default:                a=0;                break;            }        }        if(a==1)        System.out.println("Not Prime..");        else        System.out.println("Prime number..");    }    public static void main(String[]args)throws IOException    {        int x;        InputStreamReader isr=new InputStreamReader(System.in);        BufferedReader br=new BufferedReader(isr);        System.out.println("Enter the number to be checked:");        x=Integer.parseInt(br.readLine());        prime p=new prime();        p.check(x);    }}
0 0 0
The Brain
  • The Brain
  • Helper
Not sure about the answer?
Learn more with Brainly!
Having trouble with your homework?
Get free help!
  • 80% of questions are answered in under 10 minutes
  • Answers come with explanations, so that you can learn
  • Answer quality is ensured by our experts