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:
Question.java:11: error: expected
grossProfit = calculateGrossProfit(iRev, iExp);
^
Question.java:12: error: expected
System.out.println(grossProfit); // prints 30
^
Question.java:12: 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, learncs.online has a playground that you can use to experiment with your code. Here’s an example.

2 Likes

Wokay, keep it simple.

1 Like