Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add an exception handler (try/catch/throw) to the class that throws an error message (e.g. value out of range) in the getValue function that is caught

Add an exception handler (try/catch/throw) to the class that throws an error message (e.g. value out of range) in the getValue function that is caught and handled in the main program. Implement two version of the program. In version 1, throw the error in getValue, catch the error in the main, display an error message in the main, and then allow the program to PROBLEM NO.6

PROBLEM NO.7

PROBLEM NO.8

terminate. In the second version, perform the same basic actions (throw and catch) but keep re-invoking the getValue function from the main program until the user enters a valid value. // Starter Code class subRange { public: subRange( int, int ); int getValue( ); private: int lower, upper; }; subRange::subRange( int low, int high ) { lower = low; upper = high; } int subRange::getValue() { int v; cout << "Enter value [ " << lower << ", " << upper << " ]: "; cin >> v; return v; } void main() { subRange x(1,10); cout << x.getValue( ) << endl; }

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

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions