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
babunello [35]
3 years ago
13

Write an exception tester application that enables you to see the impact of exceptions being thrown. Include multiple catch clau

ses. Include the ArithmeticException, FormatException, IndexOutOfRangeException, and Exception classes. For each exception, write a try block containing errors to throw the exceptions. As you test the application, include an error that throws the exception and then comment it out and program an error that throws the next exception and so on. Your final solution should include at least one statement per exception that throws each exception. The statements should all be commented out by the time you finish testing. Be sure to include documenting comments with each statement.
Computers and Technology
1 answer:
AveGali [126]3 years ago
8 0

Answer:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

Console.WriteLine("\t\tHandling Exceptions Program");

Console.WriteLine("\n\tArithmetic Exception:\n");

// Arithmetic Exception is base class of DivideByZero Class

// Hence will be using DivideByZero Exception

int b = 0;

try

{

//Attempting Divide BY Zero

int myBadMath = (5 / b);

}

catch (System.DivideByZeroException ex)

{

Console.WriteLine("Error : Trying to divide a number by Zero");

}

//FormatException example

//Used when formats DO NOT match a data type

Console.WriteLine("\n\tFormat Exception:\n");

Console.WriteLine("Please enter a number :");

string str = Console.ReadLine();

double dNo;

try

{

//throws exception when a string is entered instead of a number

dNo = Convert.ToDouble(str);

Console.WriteLine(dNo+" : Is a valid number");

}

catch (FormatException ex)

{

Console.WriteLine("Error : "+str+" is not a valid number");

}

//IndexOutOfRangeException example

//Thrown when an element is attempted to assign or read out of the array size

Console.WriteLine("\n\tIndexOutOfRangeException Exception:\n");

try

{

//5 element array declared

int[] IntegerArray = new int[5];

//attempting 10th element. Hence error is thrown

IntegerArray[10] = 123;

}

catch (IndexOutOfRangeException)

{

Console.WriteLine("An invalid element index access was attempted.");

Console.Read();

}

}

}

}

Explanation:

You might be interested in
The users, groups, and roles that have access to a server are called ______________________________.
ElenaW [278]

Answer:

With the Exclusive Lock, a data item can be read as well as written. Also called write lock. An exclusive lock prevents any other locker from obtaining any sort of a lock on the object. They can be owned by only one transaction at a time

Explanation:

8 0
2 years ago
HURRY
Irina-Kira [14]

<em>Your answer is B: cooperative player-to-player interaction</em>

<em></em>

<em></em>

<em />

6 0
3 years ago
What does Pentium means?:/
netineya [11]
Pentium is just a brand of a CPU chips from Intel that is usually in your laptops or chromebooks. It's used for general purpose computing. Produced by Intel since 1993. 
4 0
3 years ago
Read 2 more answers
To select a number format, you can choose a category in the Number tab in the Format Cells dialog box and then select the number
siniylev [52]

Answer:

1.true

Explanation:

6 0
3 years ago
Andy intends to register his own domain name on the Internet for a minimal cost per year. Before he selects and registers a doma
Tom [10]

Answer:

.co

Explanation:

he has a company

6 0
3 years ago
Other questions:
  • A keyboard is a/an _____. interconnector port packet NAS
    7·1 answer
  • Which of the following laptop features allows users to overcome keyboard size restrictions?
    11·1 answer
  • Enterprise Resource Planning (ERP) is an example of a single user database.
    7·1 answer
  • How do you know if something is in the public domain
    5·1 answer
  • In which of the following scenarios would you choose to embed versus import data?
    8·1 answer
  • Suppose a family has had a house fire in which
    7·2 answers
  • At which track meet did two runners finish in a time equivalent to the mode?
    14·1 answer
  • A nested folder can best be described as what?
    12·1 answer
  • Luis saves an attachment that he received from Kevin. Where will the attachment save by default?
    5·1 answer
  • How to transfer polygon from eth to polygon in ledger live
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!