error in scanning inputs
Code running in eclipse not here
you should throw IOException while taking inputs, apart from that, please post your code here.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); boolean flag = true; int div = 2; while (div <= N - 1) { if (N % div == 0) { flag = false; // System.out.println(“non prime”); System.out.println(“Not Prime”);// print “Not Prime” not “non prime” return; } div = div + 1; } if (flag = true) { System.out.println(“Prime”); //print “Prime” not “prime”. } } }
still not working…and i dont know how to throw ioexception
@Mudit_Rana,
Don’t worry the code you shared is correct. Please drop a mail to [email protected] and tell them the error you are facing. Because the code is correct. Might be a technical glitch.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.