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]
4 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]4 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
Meg[] elements = {new Lois(), new Stewie(), new Meg(), new Brian()}; for (int i =0; i
Stells [14]

Complete question is attached as snapshot.

Answer:

This will result in a compilation error.

Here's the inheritance hierarchy:

Meg -> Lois -> Brian -> Stewie

Now Meg has 2 public Fxns, a() and toString().

Lois inherits from Meg and all its public functions as well but, overrides the a() fxn of its super class.

So finally Lois has fxns a(), b() and toString().

Brian extends Lois and inherits all the above listed fxns of Lois, but overrides the b() and toString() fxns.

Stewie extends Brian and inherits all the fxns of Brian, but overrides the a() and toString() fxns.

In the Main driver fxn, we call a() and b() methods of all these classes but, the base class Meg has no b() and it is not extending any class so its not available in its scope.

This results in a compilation error.

Explanation:

7 0
3 years ago
Multidimensional arrays can be stored in row major order, as in C , or in column major order, as in Fortran. Develop the access
larisa86 [58]

Answer:

Access functions explained below

Explanation:

Access functions for Three Dimensional Arrays:

Let M, N and P refer to the size of the 1st 2nd and 3rd dimensions respectively.

Element_Size is the memory size the array element.

Generic access functions for Row Major:

If character data is used then Element_Size is 1.

For i=0 to P do

For i=0 to N do

  For i=0 to M do

     Address_of _array[i, j, k] = address_of_array[0,0,0] + (i * P + j * N + k) * Element_Size

    Store data into the Address_of _array[i, j, k]

    Or

  Display data from Address_of _array[i, j, k]

end

end

end        

Generic access function for Column Major:

if For i=0 to M do

For i=0 to N do

  For i=0 to P do

     Address_of _array[i, j, k] = address_of_array[0,0,0] + (i * M + j * N + k) * Element_Size

    Store data into the Address_of _array[i, j, k]

    Or

  Display data from Address_of _array[i, j, k]

end

end

end      

3 0
4 years ago
What is a contact list?
Monica [59]

Answer:

B

Explanation:

A only describes people you've communicated with through email, so they are not necessarily contacts.

C is similar to A

D only shows email addresses, which goes along with A

8 0
3 years ago
Read 2 more answers
How much do you think it would cost to develop an app?
netineya [11]

It really depends on the type of app. There are lots of free pieces of software but distribution is expensive.

Android - $20 one  time fee

IOS - $99 per year

5 0
3 years ago
Read 2 more answers
ConnectWeb, Inc., an Internet service provider (ISP), supplies information to the Federal Trade Commission concerning possible u
Yuki888 [10]

Answer:

A Safe Harbor

Explanation:

ConnectWeb, Inc., an Internet service provider (ISP), supplies information to the Federal Trade Commission concerning possible unfair or deceptive conduct in foreign jurisdictions. For this disclosure, federal law gives ConnectWeb and other ISPs immunity from liability. This is a Safe Harbor.

5 0
3 years ago
Other questions:
  • What are the five types of alignment in word?
    8·2 answers
  • How can you tell which of the policies in the security options folder have changed settings?
    10·1 answer
  • Where should i go if i want to begin learning how to code a video game. What are your recommendations to a 16 yr old to learn co
    13·1 answer
  • Steve is creating a document with proper nouns, which Word continues to identify as being misspelled.
    10·1 answer
  • What are some ways to rename a worksheet? Check all that apply.
    9·1 answer
  • 9. which of the following cities is not considered one of the top game development hotbeds?
    15·1 answer
  • What is the dark, sticky substance that forms when tobacco is burned?
    15·1 answer
  • Trade Periodicals are usually highly scholarly resources<br> True<br><br> False
    5·1 answer
  • AI is not embraced everywhere in every industry because _______.
    7·1 answer
  • Which join is made with the following query?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!