Below is the bit of code where the “high” and “low” values from the returns previously mentioned are getting called, r.getRainAt(high)
and r.getRainAt(low)
. This is in the Main class. The method getRainAt
is in a different class. I’m not allowed to change anything in the Main.java.
I should have mentioned that earlier, but does that change anything? Would one of the approaches in the references below still work?
https://www.baeldung.com/java-method-return-multiple-values
https://www.techiedelight.com/return-multiple-values-method-java/
// Get and display the month with the highest rainfall.
high = r.getHighestMonth();
System.out.println(
"The month with the highest amount of rain " + "is " + (high + 1) + " with "
+ r.getRainAt(high) + " inches.");
// Get and display the month with the lowest rainfall.
low = r.getLowestMonth();
System.out.println(
"The month with the lowest amount of rain " + "is " + (low + 1) + " with "
+ r.getRainAt(low) + " inches.");
I have tested getRainAt
with separate if statements and made sure that they both worked to return the right element value to getRainAt(high)
and getRainAt(low)
when I returned each one at a time.