Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

12.5 Program: Divide by Zero (C++) This program will test exception handling during division. The user will enter 2 numbers and attempt to divide (in

12.5 Program: Divide by Zero (C++)

This program will test exception handling during division.

The user will enter 2 numbers and attempt to divide (in a try block) the 1st number by the 2nd number.

The program will provide for 2 different catch statements:

Division by zero - denominator is zero

Division results in a negative number

The user should be prompted with Enter 2 numbers:

For input of 7 and 0 the output should be Exception: Division by zero

For input of 7 and 2 the output should be a/b = 3.5

For input of 7 and -2 the output should be Exception: Division is negative

Instructions

Deliverables

DivideByZero.cpp

We will expect the above file(s) to be submitted

Compile command

g++ DivideByZero.cpp -Wall -o a.out

We will use this command to compile your code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

What is the profitability index? When it is used?

Answered: 1 week ago

Question

4. I give a fair hearing to fellow members ideas.

Answered: 1 week ago