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
Hurry please i need this ASAP<br><br>What might be some advantages to keeping CSS and HTML separate?
marusya05 [52]

Answer:

The separation of HTML from CSS makes it easier to maintain sites, share style sheets across pages, and tailor pages to different environments. This is referred to as the separation of structure (or: content) from presentation.

Explanation:

I think this right don't add me right then add

6 0
2 years ago
Your boss bought a new printer with a USB 3.0 port, and it came with a USB 3.0 cable. Your boss asks you: Will the printer work
Greeley [361]

Answer:

Yes, is should work

Explanation:

USB is widely adopted and supports both forward and backward compatibility. The USB 3.0 printer should work with the USB 2.0 computer. However, having a connection like this, the printer will only be able to work at the speeds of the computer’s USB 2.0. By default, USB is built to allow transfer speeds improvement with upgrades from previous generations while still maintaining compatibility between devices that are supported by them.

4 0
2 years ago
Major findings of evolution of computers
Elis [28]

Answer:

twitt

Explanation:

3 0
3 years ago
(BRAINLIEST FOR FIRST CORRECT ANSWER) Mark (all) the statements that best describe the use of spreadsheets and tables in present
mel-nik [20]

the answer is Headers should be descriptive of the cell content, The font size should be at least 18-point. hope this helps!!!

5 0
3 years ago
Moore’s law describes the pace at which ______ improve.
iren2701 [21]

Answer: CPUs

Hope it helps :) and let me know if you want me to elaborate.

7 0
2 years ago
Other questions:
  • What is a nonlinear presentation
    9·2 answers
  • What are the coordinates of (3 comma space 8 )relative to the basis open curly brackets space (1 comma space 1 )comma space (0 c
    15·1 answer
  • ​In sql server, the cursor property ____________________ means that the cursor is used for retrieval purposes only.
    9·1 answer
  • Write a program to read data from a file named problem 2. ext. This file has three exams data (floating point data) in three col
    11·1 answer
  • The difference between a for loop and a while loop is that a for loop is a loop that happens for a certain number of times. A wh
    14·1 answer
  • Difference between positional and non positional number​
    12·1 answer
  • If the algorithm does not have instructions for unanticipated results, the computer program will
    15·1 answer
  • Lori Redford, who has been a member of the Project Management group, was recently promoted to manager of the team. She has been
    12·1 answer
  • This method of file transfer has been used for decades and is frequently used for uploading changes to a website hosted by an in
    11·1 answer
  • Write a loop that continually asks the user what pets the user has until the user enters stop, in which case the loop ends. It s
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!