so the assignment is as follows

so the assignment is as follows:

I wrote an application in which you declare an array of eight first names. I wrote a try block in which you prompt the user for an integer and display the name in the requested position. I created a catch block that catches the potential ArrayIndexOutOfBoundsException thrown when the user enters a number that is out of range. The catch block also should display the error message Subscript out of range.

Here is what I have so far, but I am getting an error stating that I am missing “The BadSubscriptCaught program properly handles valid and invalid subscripts”. Any assistance would be great!

import java.util.Scanner;
public class BadSubscriptCaught
public static void main(String[] args)
String[] names = {“Ariel”, “Brad”, “Clifford”, “Denise”,”Emily”, “Fred”, “Gina”, “Henry”};
String integer;
System.out.println(“Please, enter an integer from 1 to 8 to display a name”);
Scanner input= new Scanner(;
integer = input.nextLine();
int i = Integer.parseInt(integer);
i = i-1;
catch(ArrayIndexOutOfBoundsException e)
System.out.println(“Your number is out of range”);


Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?