Ask coding questions

← Back to all posts
i made java calculator and im lost on how to fix some of the errors
TaiwoMakinwa

I was supposed to create a java calculator using parameters allowing someone to input 2 integer values and an operation (+ or -) and it outputs an answer.

Voters
TaiwoMakinwa
Comments
hotnewtop
Coder100

1. wrong class

Your class has to be called Main because that is what your file is called, so:

on line 2

Then, to set a value (lines 14 and 15)
you do not need to name the type

and you don't have to define keyboard multiple times so remove those on line 17.

Finally, you never defined methods for addition and subtraction so add those.