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
Not all hardware is connected with wires, some hardware might be connected wirelessly with
prisoha [69]

Answer:

B. Bluetooth technology.

Explanation:

A hardware platform can be defined as a collection of hardware such as an input hardware and output hardware device that are compatible with each other and the software application or program to be executed. All hardware platforms have their respective low level or high level machine language that are compatible with the software application. Some examples of a hardware devices are speakers, monitor, x86, i860, keyboard, MIPS, scanner, central processing unit (CPU) video game consoles (joysticks), IBM Z, ARM, unisys, powerpc, SPARC etc.

Generally, all hardware devices are connected with one another through the use of a wire such as cables or wirelessly such as Bluetooth, infrared etc.

Hence, not all hardware is connected with wires, some hardware might be connected wirelessly with Bluetooth technology.

A Bluetooth technology can be defined as a wireless standard used for transmitting and receiving data over a short-range of distance. Therefore, the operating radio frequency of a Bluetooth technology is 2.45 Gigahertz and for a distance of about 10 meters (30 feet).

4 0
2 years ago
Importing data is sending data to a new file.Is this true or false
Kipish [7]

false homie I gotcho


3 0
3 years ago
Read 2 more answers
OSHA requires training for employees on the hazards to which they will be exposed.
Sedaia [141]

A, OSHA does require training for employees on the hazards to which they will be exposed.


3 0
3 years ago
Read 2 more answers
Wap in java to complete the following (16*1) +(14*2) +(12*3) +(10*4) +(8*5) +(6*6) +(4*7)​
vladimir1956 [14]

Answer:

It goes like:

public class Program

{

public static void main(String[] args)

{

int j=18;

int sum=0;

for (int i =1; i<7; i++)

{

sum=sum+(i*(j-2));

j=j-2;

}

System.out.println(sum);

}

}

Explanation:

<u>Variables used: </u>

j : controls the first number in product and decreases by 2 each time the loop runs.

sum: saves the values of addition as the loop runs.

3 0
2 years ago
Have you ever been told sensitive or confidential information that made you uncomfortable? How did you deal with the situation?
Korvikt [17]
I would tell said individual to stop what they’re trying to tell me because if it’s not stuff I should know about or want to hear about then I don’t wanna hear any of it
7 0
3 years ago
Other questions:
  • This is not school related in anyway but. I used to play this videogame on my computer years ago, but i cannot remember the name
    13·2 answers
  • Which of the following is NOT one of the modules of a typical Decision Support System (DSS)? Select one: a. Customer information
    14·2 answers
  • Renee's creating a plan for her business's information system. What should she do after she determines the goals for her busines
    10·1 answer
  • General equation: y = (89 / 27) - z * x + a / (a % 2) (recall: a is an integer; the 89 and 27 constants in the equation should b
    14·1 answer
  • In vehicles equipped with ABS, the driver's foot must remain firmly on the _________ to activate the ABS.
    7·2 answers
  • If your pulse is higher than your Target Heart Rate during exercise, what should you do?
    5·2 answers
  • which scheduling algorithm allocate the CPU firt to the process that request the CPU first, (a) first come first serve,(b) short
    9·1 answer
  • How does applying Fontworks effects to text on an advertising flyer change the text?
    14·2 answers
  • Different search engines available on the internet​
    7·1 answer
  • Discuss the core technologies and provide examples of where they exist in society. Discuss how the core technologies are part of
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!