Simple Java calculator

后端 未结 10 1768
迷失自我
迷失自我 2020-12-22 02:16

Firstly this is not a homework question. I am practicing my knowledge on java. I figured a good way to do this is to write a simple program without help. Unfortunately, my c

10条回答
  •  囚心锁ツ
    2020-12-22 03:10

    Your main method needs to be declared like this:

    public static void main(String[] args) {..}
    

    Furthermore, it seems like you are only supplying one argument to your all your arithmetic methods (addition, subtraction etc), although they require two.

    public int addition(int x, int y);
    

    Can not be called with addition(operands), that is only one argument, and the argument is of the wrong type (the method needs two int, you give it a Scanner). The same goes for all those methods. You need to extract the ints from the Scanner. You can do that with Scanner.nextInt().

提交回复
热议问题