0
How can i code normal calculator using java
i have already coded that but unable to run. there a error is showing that at the last line ....where the out put will generate https://code.sololearn.com/cbC7a05gC8AN/?ref=app https://code.sololearn.com/cbC7a05gC8AN/?ref=app
3 Respuestas
+ 7
Local variables in Java are not auto initialized to 0. You have to assign an initial value to your variable c.
int c = 0;
You must not use two instances of the Scanner class within the same scope. Only one instance is enough to handle any number of inputs. Follow this practice of using Scanner:
Scanner in = new Scanner(System.in);
i = in.nextInt();
a = in.nextInt();
b = in.nextInt();
* Using break in the default clause is redundant. The default statement executes at the very last. There's no chance of a fall-through.
+ 5
You didn't initialized the variable c. Just add a line c = 0 like this:
int a, b, c, i;
c = 0;
+ 1
thanks dev