Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started