Question: // C++ Process method public: int Process() { int lNum; int sNum; int ans; cout < < Enter the largets Number < < endl;

// C++ Process method public: int Process() { int lNum; int sNum; int ans; cout << " Enter the largets Number" << endl; cin >> lNum; cout << "Enger the smallest number. " << endl; cin >> sNum; // Want to divide by largest number by the smallest ans = lNum / sNum; return ans; }

From the code above it is apparent that if ss is equal to 0 (zero) then the method will crash.

1) Use exception handling to prevent the Process() method from terminating abnormally. Only modify the Process() method.

2) Rewrite the Process() method so that the so that an exception is generated when division by zero occurs, but that exception is declared by way of an exception specifier. Do not handle the exception in this version of Process().

3) Write a method called Analyze() that calls the Process() method. In the Analyze() method, handle any specific exception thrown in the Process() method. Re-throw any exception handled in Analyze().

4) Write a main() method that calls Analyze(). Make provision in main() to handle all exceptions thrown.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!