Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

5. Complete the following tasks: a. Create an OutOfRangeException that descends

ID: 3803937 • Letter: 5

Question

5. Complete the following tasks:

a. Create an OutOfRangeException that descends from the built-in out_of_range

exception class. Include fields that hold the low and high limits of the range and the value

that was out of range. Include get functions for each of the values.

b. Create a Meal class. Data fields include a string entrée name and a double price.

Include a data entry function that prompts for and accepts values for both data fields, and

that throws an OutOfRangeException if the price is less than $5.00 or more than $29.99.

Include a public function that returns the Meal price so that you can use it in a calculation

in the Party class that you will create in part d of this problem. Also include an overloaded

insertion operator to display a Meal’s data values.

c. Create an EntertainmentAct class. Data fields include a string phone number for the

contact person for the act and a double fee for the entertainment act. Include a data entry

function that prompts for and accepts values for both data fields, and that creates and throws an OutOfRangeException if the price is less than $50.00 or more than $3,000. Include apublic function that returns the EntertainmentAct price so that you can use it in a calculation in the Party class that you will create in part d of this problem. Also include an overloaded insertion operator to display an EntertainmentAct object’s data values.

d. Create a Party class for a party-planning organization. A Party contains a Meal, an

EntertainmentAct, an integer number of guests invited to the party, and a total cost for

the party. The Party data entry function prompts the user for Meal, EntertainmentAct,

and guest number values. The function throws an OutOfRangeException if the number

of guests is less than 2 or more than 1000. The function also calculates the Party

cost, based on the Meal’s price times the number of guests, plus the price of the

EntertainmentAct.

e. Write a main()function that instantiates at least five Party objects and accepts data for

each. When you run the program, provide data that tests that each type of exception is

being recognized. The main()function should catch the exceptions and display an appropriate

error message about each including what the acceptable range was and what the

entered value was. If an exception is caught, the data for the entire Party object should be

entered again. Save the file as Party.cpp.

Explanation / Answer

#include <iostream>       // std::cerr
#include <stdexcept>      // std::out_of_range
#include <vector>         // std::vector

int main (void) {
std::vector<int> myvector(10);
try {
    myvector.at(20)=100;      // vector::at throws an out-of-range
}
catch (const std::out_of_range& oor) {
    std::cerr << "Out of Range error: " << oor.what() << ' ';
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote