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

I need this script to throw a catch block so that if the answer entered does not

ID: 3713206 • Letter: I

Question

I need this script to throw a catch block so that if the answer entered does not fall between the numeric number of 0-7 it continually asks for a number between 0-7.

public static int getType() {

int eType;

Scanner input = new Scanner(System.in);

System.out.println("Equipment types:");

for (int x = 0; x < Equipment.EQUIP_TYPES.length; ++x)

System.out.println(" " + x + " " + Equipment.EQUIP_TYPES[x]);

System.out.print("Enter equipment type >> ");

eType = input.nextInt();

return eType;

Explanation / Answer

public static int getType() { int eType; Scanner input = new Scanner(System.in); System.out.println("Equipment types:"); for (int x = 0; x 7) { System.out.println("Invaild. Please re-enter"); continue; } //break the loop break; } return eType; }
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