I wrote this code for a simple calculator and I get this error! Someone help me please!
public class Calculator {
public static void main (String[] args) {
int num1 = Integer.parseInt(args[0]);
int num2 = Integer.parseInt(args[1]);
int sum = num1 + num2;
int sub = num1 - num2;
int prod = num1 * num2;
int quot = num1 / num2;
int rem = num1 % num2;
// print the other variables, sub, prod, quot, rem;
System.out.println(num1 + " + " + num2 + " = " + sum);
System.out.println(num1 + " - " + num2 + " = " + sub);
System.out.println(num1 + " * " + num2 + " = " + prod);
System.out.println(num1 + " / " + num2 + " = " + quot);
System.out.println(num1 + " % " + num2 + " = " + rem);
}
}
Java != JavaScript;)main?if (args.length != 2) throw new IllegalArgumentException("Expected 2 arguments, but got: " + Arrays.toString(args))to the start of your main-method. This won't fix your problem, but will give you a better error message ;-).