1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
monitta
4 years ago
7

Write an application in which you declare an array of eight first names. Write a try block in which you prompt the user for an i

nteger and display the name in the requested position. Create 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.
Computers and Technology
1 answer:
meriva4 years ago
4 0

Answer:

import java.util.*;

public class Main

{

public static void main(String[] args) {

   

    String[] names = {"Ted", "Marshall","Lily", "Barney","Robin", "Stella", "Ranjit", "Wendy"};

 Scanner input= new Scanner(System.in);

 int i;

 try

 {

  System.out.print("Enter an integer(1 to 8) to display a name in that position: ");

  i = input.nextInt();

  i = i - 1;

  System.out.println(names[i]);

  input.close();

 }

 catch (ArrayIndexOutOfBoundsException e){

  System.out.println("Number is out of range!");

 }

   

}

}

Explanation:

Initialize an array containing 8 names

Inside the try block:

Ask the user for a number

Decrease the number by 1, so that it corresponds to the array index

Print the name in that position

Inside the catch block, define an ArrayIndexOutOfBoundsException that will print the error message, if the user enters a number that is not in the range

You might be interested in
Which is the answer?
vesna_86 [32]

Answer:

initial

Explanation:

When a website's creators are in the design process, storyboarding is often part of the initial stages.

3 0
3 years ago
Read 2 more answers
Convert (0.255)¹⁰ into binary<br>​
nasty-shy [4]

0.01000001010001111011

Must click thanks and mark brainliest

3 0
3 years ago
A computer is a multipurpose device that accepts input, processes data, stores data, and produces output, all according to a ser
Bingel [31]

A computer is a multipurpose device that accepts input, processes data, stores data, and produces output, all according to a series of stored <u>instructions</u>. The <u>central</u> processing unit of most modern computers is a <u>microprocessor</u>. The instructions that tell a computer how to carry out a task are referred to as computer <u>programs</u>, which are distributed as software. Computers run three main types of software: <u>Application</u> software, system software, and development tools. An example of system software is a computer <u>operating</u> system, which is essentially the master controller for all the activities that a digital device performs. Digital devices are constructed using tiny electronic components that represent data bits as electrical signals. The system unit houses the system board, which contains several <u>integrated</u> circuits made from semiconducting materials. Computers come in three popular form factors: component, <u>clamshell</u> and slate. Many of today's digital devices operate on battery power supplied by <u>Lithium</u> ion batteries. Battery life and lifespan can be extended by following good battery management practices.

<u>Explanation</u>

A computer is a multipurpose device that accepts input, processes data, stores data, and produces output, all according to a series of stored instructions. Input is data or information typed, submitted, or transmitted into a computer. Processing data involves performing calculations, drawing graphs, modifying documents, and many more. Output is the result produced by a computer. Processing is handled by the computer’s CPU (Central Processing Unit) and the central processing unit of most modern computers is a microprocessor. A microprocessor executes and manages all logical instructions passed to it and performs tasks involved in computer processing. The instructions that tell a computer how to carry out a task are referred to as computer programs, which are distributed as software. A program is software or set of ordered operations on a computer that performs a particular task or function. A program is created and compiled into a language that the computer can comprehend and then distributed as software. Computers run three main types of software: Application software, system software, and development tools. Application software are programs that help a user carry out a task while a system software helps  the computer system to monitor itself in order to function effectively. On the other hand, development tools are used for creating applications, operating systems, Web sites, and utilities. Digital devices are constructed using tiny electronic components that represent data bits as electrical signals. The system unit houses the system board, which contains several integrated circuits made from semiconducting materials. The essence of digital electronics is the small circuit boards and integrated circuits you see when you open up a digital device. ICs are sets of electronic circuits engraved onto a thin slide of semiconducting material. Computers come in three popular form factors: component, clamshell and slate. Form factor in computer terms refers to the size and dimensions of then device. Clamshell devices have features characterized by a keyboard as the base and a screen on the hinged cover. Those devices configured in the slate form factor have a touchscreen that covers majority of the device’s surface. Many of today's digital devices operate on battery power supplied by Lithium ion batteries. Battery life and lifespan can be extended by following good battery management practices. Many of today's digital devices operate on battery power supplied by Lithium ion batteries. Battery life and lifespan can be extended by following good battery management practices.

7 0
3 years ago
Carol typed a memo to send to everyone in her department. To create this memo, she used a _____.
aleksley [76]

she used a word processor

8 0
4 years ago
Read 2 more answers
Why is it important to protect people's intellectual property online?
grigory [225]
I believe that the answer is D hope this helped
6 0
3 years ago
Other questions:
  • Sara works in the IT department for a large retail store. She has been testing a theory about why an error message keeps popping
    14·1 answer
  • Can anybody answer this?
    13·1 answer
  • How has the dependence on technology made humanity less intelligent?​
    15·1 answer
  • A short story, but i remember in 1nd - 5th grade at my elementary school here is the list from first to last for being cool at s
    9·2 answers
  • Write C# program that will read name from keyboard and display it on screen. The program should throw an exception when the leng
    6·1 answer
  • What does the sign (#) mean in manuscript edpm<br> and also what does (DEL)
    15·1 answer
  • How does defragmentation improve performance?
    9·1 answer
  • Describe the role of a distributed file system in a job execution environment such as MapReduce in a large-scale cloud system. g
    11·1 answer
  • What will be the result from running the following program?
    6·1 answer
  • I have a .NET 6 basic website that I built using Entity Framework as the database for updating pages. I am ready to deploy the s
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!