![subject](/tpl/images/cats/informatica.png)
Computers and Technology, 12.10.2021 06:00 babyskitt
Java
Given an array of 10 names, complete the main method that outputs the name specified by the array index entered by the user. Use a try block to output the name and a catch block to catch any . Output the message from the exception object if an is caught. Output the first element in the array if the index is negative or the last element if the index is greater than the size of the array.
Hint: Format the exception outputs using the getMessage() method from the exception object. Do not hard code the exception messages.
Ex: If the input of the program is:
5
the program outputs:
Name: Jane
Ex: If the input of the program is:
12
the program outputs:
Exception! Index 12 out of bounds for length 10
The closest name is: Johnny
Ex: If the input of the program is:
-2
the program outputs:
Exception! Index -2 out of bounds for length 10
The closest name is: Ryley
import java. util. Scanner;
public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System. in);
String[] names = { "Ryley", "Edan", "Reagan", "Henry", "Caius", "Jane", "Guto", "Sonya", "Tyrese", "Johnny" };
int index;
index = scnr. nextInt();
try {
}
}
}
![ansver](/tpl/images/cats/User.png)
Answers: 1
Another question on Computers and Technology
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 04:00
Write a method that takes in an array of point2d objects, and then analyzes the dataset to find points that are close together. be sure to review the point2d api. in your method, if the distance between any pair of points is less than 10, display the distance and the (x,y)s of each point. for example, "the distance between (3,5) and (8,9) is 6.40312." the complete api for the point2d adt may be viewed at ~pf/sedgewick-wayne/algs4/documentation/point2d.html (links to an external site.)links to an external site.. try to write your program directly from the api - do not review the adt's source code.
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 12:00
What type of slide show is a dynamic and eye-catching way to familiarize potential customers with what your company has to offer? a. ole b. photo album c. brochure d. office clipboard
Answers: 2
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 17:00
What are the 12 colors of the spectrum called?
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 20:30
Column a of irma’s spreadsheet contains titles for each row, but her document is too big and will be printed three pages across. she wants to be sure that every page will be understood. what can irma do to with this problem?
Answers: 3
You know the right answer?
Java
Given an array of 10 names, complete the main method that outputs the name specified by the a...
Questions
![question](/tpl/images/cats/mat.png)
Mathematics, 02.02.2021 22:00
![question](/tpl/images/cats/mat.png)
Mathematics, 02.02.2021 22:00
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 02.02.2021 22:00
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 02.02.2021 22:00
![question](/tpl/images/cats/mat.png)
Mathematics, 02.02.2021 22:00
![question](/tpl/images/cats/himiya.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 02.02.2021 22:00
![question](/tpl/images/cats/mat.png)
Mathematics, 02.02.2021 22:00
![question](/tpl/images/cats/mkx.png)
Arts, 02.02.2021 22:00
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/en.png)
English, 02.02.2021 22:00
![question](/tpl/images/cats/mat.png)
Mathematics, 02.02.2021 22:00
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/en.png)
English, 02.02.2021 22:00