Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define an exception class called tornadoException. The class should have two constructors, including the default constructor. If the exception is thrown with the default constructor,

Define an exception class called tornadoException. The class should have two constructors, including the default constructor. If the exception is thrown with the default constructor, the method what should return "Tornado: Take cover immediately!". The other constructor has a single parameter, say, m, of the int type. If the exception is thrown with this constructor, the method what should return "Tornado: m miles away; and approaching!". You decide what value of m should be used to trigger the non-default warning. Write a program to test this class.

Here is a standard way to create the message using the integer parameter. There are nonstandard ways to do this which are compiler-dependent. Please use this method for this program so you will know what to do if you use a compiler that does not support one of the nonstandard methods.

#include // Include the stringstream library #include using namespace std; int main() { double balance = 250.75; // Declare a stringstream buffer variable stringstream ss; string message; // Stream your output to the stringstream buffer ss << "You have a balance of: $" << balance; // Convert the characters in the stringstream buffer to a string message = ss.str(); cout << message << endl; return 0; }

Turn in your tornadoException.h file and your test program. Also turn in one or more screen shots showing the results of your testing.

Once completed you will demonstrate that you can

Construct a user-defined exception class.

Throw an exception which generates a default message

Throw an exception which generates a message from a parameter sent through an exception object.

Handle an exception using catch blocks.

Generate a string which incorporates a numeric value using the stringstream library.

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

Step: 3

blur-text-image

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

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

Students also viewed these Databases questions

Question

Write the numbers in Problems 1215 in base ten. 1111011 two

Answered: 1 week ago

Question

2. Show the trainees how to do it without saying anything.

Answered: 1 week ago