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
liubo4ka [24]
3 years ago
5

In C#Write the program SubscriptExceptionTest in which you use an array of 10 doubles. Write a try block in which you place a lo

op that prompts the user for a subscript value and displays the value stored in the corresponding array position or asks the user to quit the program by entering 99. Create a catch block that catches any IndexOutOfRangeException and displays the message: Index was outside the bounds of the array.
Computers and Technology
1 answer:
Leviafan [203]3 years ago
8 0

Answer:

using System;

namespace ConsoleApp3

{

   class Program

   {

       static void Main(string[] args)

       {

           double[] doubleArray = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };

           Console.WriteLine("Double Array values are:");

           foreach (var b in doubleArray)

           {

               Console.WriteLine(b);

           }

           Console.WriteLine("Enter value to find position in Array");

           var input = Console.ReadLine();

           var value = Convert.ToDouble(input);

           if (value == 99.0)

           {

               Environment.Exit(0);

           }

           try

           {

               var index = Array.IndexOf(doubleArray, value);

               if (index == -1)

               {

                   Console.WriteLine("Index was outside the bounds of the array");

                   Console.ReadLine();

               }

               else

               {

                   Console.WriteLine("Position in Array is:" + index);

                   Console.ReadLine();

               }

           }

           catch (Exception e)

           {

               Console.WriteLine("Index was outside the bounds of the array");

               Console.ReadLine();

           }

       }

   }

}

Explanation:

this is the code of console program which initialize the double array from 1-10 and displays the existing values of array in console.

Then it will take input from user, convert it to double and find the value position in double array.

if 99, then program will be exist

if exist in array:display the index position

else:index was outside the bounds of the array in try catch block.

You might be interested in
How much is a stock supra 1998​
saveliy_v [14]

Answer:

Hatchback Original MSRP / Price Engine

Supra 3dr LB Auto $31,078 / $29,122 6 Cylinder

Supra 3dr LB Sport Roof Auto $35,648 / $32,842 6 Cylinder

Supra 3dr LB Sport Roof Turbo Auto $38,778 / $35,903 6 Cylinder Turbo

Supra 3dr LB Sport Roof Turbo Manual $40,508 / $37,362 6 Cylinder Turbo

Explanation:

5 0
2 years ago
Which of the following actions is most likely to be effective in reducing the digital divide at a local level? A Creating an app
Mekhanik [1.2K]

Answer: C

Explanation:

4 0
2 years ago
1.<br> The correct way to use a seat belt is
Nesterboy [21]

Answer:

4 steps

Explanation:

Step 1: Pull belt across body

Sit in any of your vehicle's seats and secure the three-point harness in its buckle by pulling it across your body.

If the seatbelt is too short, consider an aftermarket restraint and extender. Make sure they meet federal safety standards and are installed professionally.

Step 2: Adjust lower belt

Adjust the lower belt snuggly across your lap and pelvis area – never your stomach.

Pregnant women should wear the lap belt below their belly, not on or above it.

Step 3: Adjust shoulder belt

Adjust the shoulder belt to fit comfortably across the collarbone and chest. It should never rub on your neck or face. Never put the shoulder belt behind your back or under your arm.

Step 4: Check before driving

Check that the belt is secure before driving.

4 0
2 years ago
a) What are the 'interrupts' in a computer system? Describe the approaches to deal with multiple interrupts in a system.b) Analy
Fynjy0 [20]

Answer:

a)

An interrupt is a signal sent to the processor which indicates an event that needs immediate attention.

  • Interrupts are usually sent to CPU by external or I/O devices.
  • This notifies the processor to a high-priority process that requires the current process to be disrupted.
  • Interrupts requests the processor to stop its ongoing operations and run appropriate part of OS.
  • If the request is acknowledged, the processor may respond by halting its current operation, saving its state. Processor then executes a function called an interrupt handler to handle the event that needs attention.
  • This interrupt is temporary, and processor continues normal activities after the interrupt operator stops, unless the interrupt shows a fatal error.
  • The CPU must inform the device that its interrupt request is acknowledged so that it stops sending interrupt signals.
  • Interrupts are usually used for multitasking purposes in real time computers.
  • There are two basic types of interrupts: hardware and software interrupts.
  • A hardware interrupt requests are generated by hardware devices, to indicate that it needs attention from the operating system.
  • Software interrupts are either requested by programs when they want  some service from the operating system or these interrupts are generated by processor itself on executing particular instructions or when certain requirements are met.

Approaches to deal with multiple interrupts:

There are two approaches to handle multiple interrupts.

  1. One approach is to disable interrupts while an interrupt is being processed. A disabled interrupt means that processor will ignore that interrupt request. If during this phase an interrupt happens, it usually remains pending and will be reviewed by the processor after the interrupts has been enabled by the processor. So, when a program is being executed and an interrupt happens, interrupts are disabled immediately.Upon completion of the interrupt handler procedure, interrupts are allowed before the user program resumes, and the processor checks if other interrupts have occurred. This is a simple technique which deals with the interrupts sequentially. But it does not deal with priority requirements.
  2. Second approach is to define interrupt priorities to enable a higher priority interrupt to cause disruption of a lower-priority interrupt handler. For example take a system with 3 I/O devices: printer, disk and communication line with priorities 3,5, and 7. Lets say when a program starts a printer interrupt happens. The execution continues at printer ISR. At some time interval communication interrupt happens whilst this ISR is still executing. Due to the higher priority of the communication line than the printer, the interrupt is accepted and printer routine is interrupted. Its state is placed on stack and now execution resumes at communication line ISR. Now at some time interval the disk interrupt happens while communication routine is still executing. As the priority of disk interrupt is lower so this is held and communication isr execute completely. Suppose communication ISR finishes, then the previous state is resumed which is printer's ISR execution. But as the disk has higher priority than printer, the processor continues execution in disk ISR. After the completion of disk routine execution, the printer ISR is resumed. After the printer ISR execution is completed the control goes back to the user program.

b) Benefits of using multiple bus architecture compared to single bus architecture are as follows:

  • In a multiple bus architecture each pathway is tailored to deal with a specific type of information. This enhances performance as compared to single bus architecture which is used by simple computers to transfer data onto single bus. Performance enhancement is an important reason for having multiple buses for a computer system.
  • Multiple bus architecture allows multiple devices to work at the same time. This reduces waiting time and enhances the speed of the computer as compared to single bus architecture in which all the components share a common bus. Sharing a common bus causes bus contention which results in slowing down the computer and waiting time increases.
  • Having several different buses available allows to have multiple choices for connecting devices to computer system.
  • Bus designs changes, with the introduction of new types and forms from time to time. Multiple bus architecture with several buses can support equipment from different time periods and helps to retain obsolete equipment such as printers and old hard drives, and also add new ones. This is the compatibility benefit of using multiple bus architecture.
  • CPU places heavy load on bus which carries data from memory and peripheral traffic. So nowadays computers take on multi core model with multiple buses required. So multiple bus architecture is a good option for such systems as it carries more amounts of data through the processor with minimum wait time.

3 0
2 years ago
Write a Python function that takes a positive integer N and returns the factorial of N, i.e., N! The factorial of N, denoted N!,
sesenic [268]

Answer:

The python function is as follows:

def fact(N):

   factorial = 1

   for i in range(1,N+1):

       factorial = factorial * i

   return(factorial)

Explanation:

This line defines the function

def fact(N):

This line initializes the product of 1 to N to 1

   factorial = 1

This line iterates through 1 to N

   for i in range(1,N+1):

This line calculates the product of 1 to N i.e. factorial

       factorial = factorial * i

This line returns the factorial

   return(factorial)

6 0
2 years ago
Other questions:
  • A bit shift is a procedure whereby the bits in a bit string are moved to the left or to the right. For example, we can shift the
    12·1 answer
  • List some good names for devices on your home network or on the network in your school's lab. Demonstrate the use of best practi
    13·1 answer
  • Assume that x is a string variable has been given a value. Write an expression whose value is true if and only if x is an hexade
    9·1 answer
  • What is WEB 1.0 to WEB3.0
    11·1 answer
  • A large amount of scatter in a scatterplot is a indication that the association between the two variables is
    13·2 answers
  • Submit your 400-word essay that analyzes and evaluates three different examples of digital media. need some help
    14·1 answer
  • Please answer me fast ​
    6·2 answers
  • Is there a way of how to delete this if so pleas tell me
    11·1 answer
  • Write a paragraph discussing privacy issues on the internet<br> and their impact on human lives.
    9·1 answer
  • In MS Word we can merga cells true or false​
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!