Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++, modify the following program so that it has another exception named FailingInputException . If the user inputs a grade < 60, the program

In C++, modify the following program so that it has another exception named FailingInputException. If the user inputs a grade < 60, the program should display a message that we don't allow failing grades and then continue accepting grades. The totals should be revised so that only 4 totals are displayed.

This is the code that needs to be altered:

#include  using namespace std; class NegativeInputException { public: NegativeInputException() { cout << "End of input data reached "; } }; // end NegativeInputException class int main() // Any exception can be raised { int new_grade, index, limit_1, limit_2; int freq[10] = {0}; // Exception to deal with end of data try { while (true) { cout << "Please input a grade or -1 to end: "; cin >> new_grade; if (new_grade < 0) // Terminating condition throw NegativeInputException(); index = new_grade / 10; { try { if (index > 9) throw new_grade; freq[index]++; } catch (int grade) { // Handler for index error if (grade == 100) freq[9]++; else cout << "Error: " << grade << " out of range! "; } // end of catch(int grade) } // end of inner try-catch pari } // end of while } // end of outer try block catch (NegativeInputException e) { // Handler for negative cout << "Limits Frequency "; for (index = 0; index < 10; index++) { limit_1 = 10 *index; limit_2 = limit_1 + 9; if (index == 9) limit_2 = 100; cout << limit_1 << " " << limit_2 << " " << freq[index] << endl; } // end for } // end catch (negative int) system("pause"); } // end main

PreviousNext

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

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions

Question

What is an industry?

Answered: 1 week ago

Question

3. How would you address the problems that make up the situation?

Answered: 1 week ago

Question

2. What recommendations will you make to the city council?

Answered: 1 week ago