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
Using a windows computer, to expand a branch of the folder tree you would _____.
s344n2d4d5 [400]
A folder can include everything from documents and music, to applications [like Word or Excel or your favorite browser]. But computer folders can also contain other folders, lots of them, and those sub-folders can contain folders of their own. This is the called folder tree. The trunk of the tree is the Desktop. Then there are several folders like Recycle Bin, Control Panel,..The most important branch is the one called ‘Libraries’. Here are the Photos, Music, Videos,...
<span>Using a windows computer, to expand a branch of the folder tree you would right click </span>beside various folders and drives to expand the folder tree.

8 0
3 years ago
Assume you have a button control named btndisplaylist. Which is the default name for an event procedure that will be executed wh
dybincka [34]

The default name for an event procedure that will be executed when the user clicks on the control will be btnDisplayListclick.

<h3>What is a default name?</h3>

It should be noted that a default name means a name that's assigned to a folder that's created in a computer.

In this case, the default name for an event procedure that will be executed when the user clicks on the control will be btnDisplayListclick.

Learn more about default on:

brainly.com/question/23976472

#SPJ12

8 0
2 years ago
You received a call form a user who brought her own device to the office but cannot find or connect to the company WLAN. The lap
lapo4ka [179]

Answer:

Company WAP has SSID broadcast disable

Explanation:

Disabling SSID broadcast will make your WLAN network name invisible to other users. However, this only hides the name, not the network itself. that's why the user cannot find the company WLAN on her computer but yet can connected to the company WLAN and can browse to multiple websites with no problem from their company-assigned laptops.

8 0
3 years ago
Write a method called classAttendence() that creates a 10-by-10 two-dimensional array and asks for user input to populate it wit
gladu [14]

Answer:

The method written in Java is as follows:

public static void classAttendance(){

   Scanner input = new Scanner(System.in);

   String[][] names = new String[10][10];

   for(int i =0;i<10;i++){

    for(int j =0;j<10;j++){

       System.out.print("Student Name: "+(i+1)+" , "+(j+1)+": ");

       names[i][j] = input.nextLine();        

    }  

   }

}

Explanation:

This defines the classAttendance() method

public static void classAttendance(){

   Scanner input = new Scanner(System.in);

This declares the 2D array of 10 by 10 dimension as string

   String[][] names = new String[10][10];

This iterates through the rows of the array

   for(int i =0;i<10;i++){

This iterates through the columns of the array

    for(int j =0;j<10;j++){

This prompts user for student name

       System.out.print("Student Name: "+(i+1)+" , "+(j+1)+": ");

This gets the student name from the user

       names[i][j] = input.nextLine();        

    }  

   }

The method ends here

}

<em>See attachment for complete program that include main method</em>

Download txt
6 0
2 years ago
13 POINTS! Which option is used to ensure the integrity and authenticity of a Word document but requires additional services to
Ksju [112]

A. digital encryption

5 0
3 years ago
Read 2 more answers
Other questions:
  • Which statement describes what happens if multiple users make changes simultaneously to a presentation when
    10·1 answer
  • 1. What is the main factor that affects Earth’s average temperature?
    12·1 answer
  • Which feature enables you to make changes to all the slides of your presentation at the same time?
    15·2 answers
  • What is the impact of information technology in your daily life?
    12·1 answer
  • Provide the instruction type, assembly language instruction, and binary representation of instruction described by the following
    7·1 answer
  • 9.1.3: Printing vector elements with a for loop. Write a for loop to print all NUM_VALS elements of vector courseGrades, followi
    5·1 answer
  • D) Informal high level descuption of an algorithm in english kcalled
    9·2 answers
  • I'm trying to move the figure a little away from, the column line and every time I move it and click ok it goes back to being be
    11·1 answer
  • What is the output by the code system.out.print(8-4+2);
    13·1 answer
  • 4. When working at the CLI in Linux, you specify the exact location of a file, which is the ____________________ to it, by begin
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!