My program is suppose to calculate the bonus using a multidimensional array, based the weeks and reviews, I try to make the program fail, it returns the right string, but in the output box, tells me exception, How do I stop the exception within a multidimensional Array? Below is the code and Output.
static int bonus[][] = {{5, 9, 16, 22, 44},
{10, 12, 18, 25, 36},
{20, 25, 32, 42, 53},
{32, 38, 45, 55, 68},
{46, 54, 65, 77, 90},
{60, 72, 84, 96, 120},
{85, 100, 120, 140, 175}};
static int weeks;
static int reviews;
calcButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
weeks = Integer.parseInt(weeksWorked.getText());
if (weeks > 6) {
weeks = 6;
}
else if(weeks < 0){
outputBox.setText("Invalid Number");
}
reviews = Integer.parseInt(weeksWorked.getText());
if (reviews > 4) {
reviews = 4;
}
this.outputBox.setText("$" + bonus[weeks][reviews]);
}