I'm working on an assignment and I'm not allowed to use Scanner. Instead we have to use int money = Integer.parseInt(args[0]). I tried writing my code and it compiles but there is a run time error and I was wondering if someone could tell me what I'm doing wrong to get me on the right track!
Here's my code:
class MakingChange {
public static void main(String[] args) {
int money = Integer.parseInt(args[0]);
int toonies = (money / 200);
System.out.println(toonies);
}
}
And the error is
java.lang.ArrayIndexOutOfBoundsException: 0
at Money.main(Money.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:272)
I don't know what to make of this error! Any help would be greatly appreciated