Basic calculator doubt


In challenges-Fundamentals and Patterns there in question “Basic Calculator” i wrote the above code.The output is below :
TESTCASE # 1 : wrong-answer (Time: 0.06 s)
TESTCASE # 2 : run-error (Time: 0.05 s)
TESTCASE # 3 : run-error (Time: 0.05 s)
TESTCASE # 4 : wrong-answer (Time: 0.06 s)
TESTCASE # 5 : correct (Time: 0.05 s)
TESTCASE # 6 : correct (Time: 0.07 s)

Can you tell what’s wrong in the code.
also in question it is not specified what to do if the input N2 =0 in case of division and modulos.

Hi Nirbhay,
Scanner object must be declare outside the while loop because when you declare inside the while loop multiple times scanner object gets created and that’s why compiler get confused which scanner object is to be used. Also re initialization of flag to zero must be outside the switch block as no matter what the case is loop should always run.

I have made above mentioned changes in your code and you can check them in link: https://ide.codingblocks.com/s/81695

Your code is showing more errors than mine. Please look into it