Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What I need: In C#: Write the program SubscriptExceptionTest in which you use an array of 10 doubles. Write a try block in which you

What I need:

In C#: Write the program SubscriptExceptionTest in which you use an array of 10 doubles. Write a try block in which you place a loop 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.

What I have:

using System; public class SubscriptExceptionTest { public static void Main() {bool isNumValue = false; int num=0; do {try {Console.Write(" Enter a number."); num = Convert.ToInt32(Console.ReadLine()); numList.DisplayValue(num); isNumValue=true;} catch (IndexOutOfRangeException e) {Console.WriteLine(e.Message + " The value you entered is {0}",num); Console.WriteLine("Index was outside the bounds of the array"); isNumValue=false;}} while(isNumValue);} } class numList { private static double [] value = {20.3, 44.6, 32.5, 46.7, 89.6, 67.5, 12.3, 14.6, 22.1, 13.6}; public static void DisplayValue(int num) {Console.WriteLine("The value of your entered number is " + value[num].ToString("C"));} }

Problem:

I need it to implement that the application stops asking for new numbers when 99 is entered instead of saying it is outside of the array,

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

1. Let a, b R, a Answered: 1 week ago

Answered: 1 week ago

Question

Compare levels of resolution in conflict outcomes?

Answered: 1 week ago

Question

Strategies for Managing Conflict Conflict Outcomes?

Answered: 1 week ago