Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Programming Joyce Farrell, 8th editon exercise 10 pg 486, I need help creat

ID: 3866085 • Letter: J

Question

Java Programming Joyce Farrell, 8th editon exercise 10 pg 486, I need help creating a Gui for the program it works but error keeps getting thrown, Here is my code, and Output, I need to stop the execption error from appearing:

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 = 6;
static int reviews = 4;

× E8.2 urce Refactor Run Debug Profile Team Iools Window Help Weeks Worked1 Postive Reviews Invalid Number T F age EB multiArrayLecture Java ×MorgansBonusesjava ×BPhoneArrayjava ComputerCreationjava @SuppressWarnings ("unchecked") Generated Code 36 37 103 104 105 106 D 107 E 108 D 109 private void calcButtonActionPerformed (java.awt.event.ActionEvent evt) / TOD0 add your handling code here: veeks Integer.parseInt (weeksWorked.getText()); if (veeks6) weeks = 6; 112 113 o 114 if (veeks 4) reviews 4 : run: Exception thread "AT-EventQueue-0" java lang . ArrayIndexOutOfBoundsException: -1 in at MorgansBonuses.calcButtonAction Performed (MorgansBonuses.java: 123) at MorgansBonuses.access$000 (MorgansBonuses.java: 13) at MorgansBonuses$1.actionPerformed (MorgansBonuses.java:56) at javax.swing. AbstractButton.fireActionPerformed (AbstractButton. java:2022)

Explanation / Answer

static int weeks = 6;
static int reviews = 4;

You declared as static and you are reassigning the value as

weeks = Integer.parseInt(weeksWorked.getText());
reviews = Integer.parseInt(weeksWorked.getText());

Static is meant for not reassigning the value but we can do increment and decrement of value

try removing static for weeks and reviews and remove static for bonus array as well.

If you face issues further, just paste the full code, so that I can solve your bug.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote