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
During Iteration planning, the PO introduces multiple new stories to the team. After a lot of discussion, the team decides to in
netineya [11]

Answer:

The answer is "Option d".

Explanation:

The Iteration Management is also an activity in which all members of the team will determine how many the backlog team will allocate towards the next Iteration, and each team wraps up the work only as a group of determined iteration targets. in the given question the "choice d" is correct because The plans to achieve without training entered PO or design staff and requirements have not even been identified, and the wrong choice can be defined as follows:

  • In choice A, T' he PO doesn't give the story detail, that's why it's incorrect.    
  • In choice B,  the doesn't a team left the past for more refining with the PO in the Project Backlog, that's why it's incorrect.  
  • In choice C, The Development Team has not found some other team dependency, that's why it's incorrect.

4 0
3 years ago
Which decimal value (base 10) is equal to the binary number 1012?
GaryK [48]

Answer:

The decimal value of 101₂² base 2 = 25 base 10

Explanation:

The number 101₂² in decimal value is found as follows;

101₂ × 101₂ = 101₂ + 0₂ + 10100₂

We note that in 101 + 10100 the resultant 2 in the hundred position will have to be converted to a zero while carrying over 1 to the thousand position to give;

101₂ + 0₂ + 10100₂ = 11001₂

Therefore;

101₂² =  11001₂

We now convert the result of the square of the base 2 number, 101², which is 11001₂ to base 10 as follows;

Therefore converting 11001₂ to base 10 gives;

11001₂= 1 × 2⁴ + 1 × 2³ + 0 × 2² + 0 × 2 ¹ + 1 × 2⁰

Which gives;

16 + 8 + 0 + 0 + 1 = 25₁₀.

7 0
3 years ago
Which feature of a social news sharing website distinguishes it from a social bookmarking website
Crank
The privacy feature i think
4 0
3 years ago
Read 2 more answers
Archie wants to optimize an XFS filesystem and minimize the chance of future corruption. Which of the following commands will co
svlad2 [7]

Answer:

The best answer is "B"

xfs_fsr

Explanation:

The is a typical format of the command to use:

xfs_metadump -o /dev/sdb1 /reviewxfs

6 0
3 years ago
Read 2 more answers
The TechWorld goes on a fast pace, what do you think would be the solution to the growing amount of data being collected by the
Nuetrik [128]

The solution to the growing amount of data in software applications to have fully sustainable usage for customers is;

  • Development of a sustainable model for the future now requires data storage that is engineered to be lower power requirements, lower cooling requirements, and lower waste production.

<h3>Sustainable data storage and usage</h3>

The objective of Sustainable Data Storage Initiative is to spread awareness of the solutions that can reduce the environmental impact of high waste producing data centers.

The environmental impact of data infrastructure is growing as data workloads increase. Hence, building a sustainable model for the future now requires data storage that is engineered to be lower power requirements, lower cooling requirements, and lower waste production.

Read more on Sustainable data storage and usage;

brainly.com/question/24882256

7 0
2 years ago
Other questions:
  • Use the drop-down menus to complete the statements about using section breaks in a document
    9·1 answer
  • What should you do if ads keep popping up on your computer when using Google Chrome?
    14·1 answer
  • Stephen needs to insert a field into a building block that will contain variable data. Which keyboard shortcut can he use to tog
    6·1 answer
  • The Company management has asked that you compare the OSSTMM and the PTES to determine which methodology to select for internal
    13·1 answer
  • Write a program that prompts the user to input a number. The program should then output the number and a message saying whether
    10·1 answer
  • A(n) ____ instruction might look like a meaningless string of 0s and 1s, but it actually represents specific operations and stor
    9·1 answer
  • Given the integer variables x, y, and z, write a fragment of code that assigns the smallest of x, y, and z to another integer va
    7·1 answer
  • What do you need for digital photography? 1. 2. 3.
    13·1 answer
  • 1. A cell is identified by its ........
    8·1 answer
  • What is a simple definition for electricity?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!