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 Copyright Act of 1976 statute extends protection to owners of _____________________, but this act by itself does not prevent
Debora [2.8K]

Answer:

The Copyright Act of 1976 statute extends protection to owners of the <u>artistic work.</u>

Explanation:

The Copyright Act of 1976 is a copyright law of the United States of America. This act came into effect on January 1, 1978. The copyright act states the basic rights of the copyright holders and extends protection to the original artistic works of authorship such as graphic work, literary work, musical work, graphic work, motion pictures etc.

3 0
3 years ago
A plan to budget time for studying and activities is referred to as a study routine. study habits. study skills. a study schedul
vesna_86 [32]

Answer:

A study routine

Explanation:

6 0
3 years ago
Read 2 more answers
Write a method named decimalToBinary that accepts an integer as a parameter and returns an integer whose digits look like that n
zmey [24]

Answer:

In Java:

public static int decimalToBinary(int decimal){

int binary = 0; // initial value

int currUnitPlace = 1; // working location

while(decimal > 0) {

// put remainder in current unit place

binary += currUnitPlace * (decimal%2);

decimal /= 2; // move to next bit

currUnitPlace *= 10; // move unit place

}

return binary;

}

7 0
3 years ago
How can you best explain server side caching with web pages​
maksim [4K]

Answer:

Server side web caching typically involves utilizing a web proxy which retains web responses from the web servers it sits in front of, effectively reducing their load and latency.

Explanation:

4 0
3 years ago
On the Excel Ribbon, click the Data tab in the Sort &amp; Filter Group, and then click the Sort button to conduct a _____ sort.
Stels [109]

Answer:

a. Table range

Explanation:

Excel is used for maintaining the data of the company. It contains various formulas, features like pivot table, macros, sort & filter group so the firm could able to present its data in an effective and efficient way

Here the sort button is used to ascending or descending the table based on the name, values, etc

So in the given situation, the first option is correct

4 0
3 years ago
Other questions:
  • Mr. Cooper would like to customize his Excel software so his students can create an electronic graph in Excel for their lab repo
    6·1 answer
  • Who played a leading role in perfecting movable type for printing?
    15·1 answer
  • Who were called “freedmen” during the reconstruction period?
    15·2 answers
  • 2.1. The stream cipher described in Definition 2.1.1 can easily be generalized to work in alphabets other than the binary one. F
    10·1 answer
  • 4. An abstract data type is defined as _____.
    14·1 answer
  • Which of the following is the core communications protocol for the internet? telnet ftp tcp/ip ssl
    11·1 answer
  • The objective of an Enterprise Resource Planning (ERP) system is to create a customized software program that integrates the inf
    15·1 answer
  • Consider an application that transmits data at a steady rate (for example, the sender generates N-bit unit of data every k time
    7·1 answer
  • Write a program that accepts a positive integer N as command-line argument, and outputs True if N is the square of some integer,
    13·1 answer
  • second question today 25 POINTS: What is the formula to balance a lever when both effort and resistance are present?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!