Errors & Debugging:

Homework: Accounting Calculator
Doesn’t recognize grossProfit; has been initialized as: int grossProfit = 0;
This code worked in Visual Studio Code.
Error messages: error: expected
grossProfit = calculateGrossProfit(iRev, iExp);
^ error: expected
System.out.println(grossProfit); // prints 30
^ error: expected
System.out.println(grossProfit); // prints 30

1 Like

Welcome! Make sure that you’re only providing the method definition, and not an entire class. (Our playgrounds and homework environment work a bit differently from Visual Studio.)

Here’s an example to get you started:

int calculateGrossProfit(int[] first, int[] second) {
  return 0;

In a few more lessons we’ll have you writing complete classes, which will look more like what you’d find in Visual Studio Code.

FYI, has a playground that you can use to experiment with your code. Here’s an example.


Wokay, keep it simple.

1 Like