Computer Science, asked by vikash002, 1 year ago

write any java program using Buffered reader

Answers

Answered by charlie1505
0

Answer:

Java prg using bufferedReader

eg- prime no

import java.io.*;

class PrimeNumber

{

public static void main(String args[] )

throws IOException

{

BufferedReader Prime=new BufferedReader(new InputStreamReader(System.in));

String CPN;

int i,x,Number,m;

System.out.print("Check Number to Prime or Not : ");

CPN=Prime.readLine();

Number=Integer.parseInt(CPN);

x=0;

for(i=2;i<=Number-1;i++)

{

m=Number%i;

if(m==0)

{

System.out.println(Number +" Number is not Prime");

x=1;

break;

}

}

if(x==0)

{

System.out.println(Number +" Number is a Prime Number");

}

}

}

Similar questions