C++ Help converting existing assignment to use classes. Original assignment: Create a program that calculates the hypotenuse of a triangle, the area of a trapezoid, and the volume of a rectangle. The user must input the variables in the formulas. Changes to be made: Convert previous assignment to utilize a class structure in portable .h and .cpp files Exit the program only on user demand code: //dispays menu void displayMenu() {    cout << "Please Choose a calculation function" << endl;    cout << endl;    cout << "Enter 1 to calculate the hypotenuse of a triangle of a triangle" << endl;    cout << endl;    cout << "Enter 2 to calculate the area of a trapezoid" << endl;    cout << endl;    cout << "Enter 3 to calculate the volume of a rectangular prism" << endl;    cout << endl;    cout << "Enter any other letter or number input to exit" << endl; } //hypotenuse of triangle and associated functions double calculateHypotenuse(double sideA, double sideB) {    double hypotenuse = sqrt((sideA * sideA) + (sideB * sideB));    return hypotenuse; } void hypotenuseMenuOption() {    double side1;    double side2;    cout << "Enter the measurement of the base of the triangle" << endl;    cin >> side1;    cout << "Enter the measurement of the height of the triangle" << endl;    cin >> side2;    cout << endl;    cout << " The hypotenuse of the triangle is: " << calculateHypotenuse(side1, side2); } //trapezoid area and associated functions double calculateTrapezoidArea(double base1, double base2, double height) {    double area = ((base1 + base2) / 2) * height;    return area; } void trapezoidAreaMenuOption() {    double b1;    double b2;    double h;    cout << "Enter the first base of the trapezoid" << endl;    cin >> b1;    cout << "Enter the second base of the trapezoid" << endl;    cin >> b2;    cout << "Enter the height of the trapezoid" << endl;    cin >> h;    cout << endl;    cout << "The area of the trapezoid is: " << calculateTrapezoidArea(b1, b2, h); } //volume of a rectangular prism and associated functions double calculateRectangleVolume(double length, double width, double height) {    double volume = length * width * height;    return volume; } void rectangleVolumeMenuOption() {    double rectangleLength;    double rectangleWidth;    double rectangleHeight;    cout << "Enter the length of the rectangle" << endl;    cin >> rectangleLength;    cout << "Enter the width of the rectangle" << endl;    cin >> rectangleWidth;    cout << "Enter the height of the rectangle" << endl;    cin >> rectangleHeight;    cout << endl;    cout << "The volume of the rectangular prism is: " << calculateRectangleVolume(rectangleLength, rectangleWidth, rectangleHeight); } //driver int main() {    displayMenu();    int menuChoice;    cin >> menuChoice;    if (menuChoice == 1) {        hypotenuseMenuOption();    }    else if (menuChoice == 2) {        trapezoidAreaMenuOption();    }    else if (menuChoice == 3) {        rectangleVolumeMenuOption();    }    else {        exit(0);    }

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 6RQ
icon
Related questions
Question

C++ Help converting existing assignment to use classes.

Original assignment:
Create a program that calculates the hypotenuse of a triangle, the area of a trapezoid, and the volume of a rectangle. The user must input the variables in the formulas.
Changes to be made:
Convert previous assignment to utilize a class structure in portable .h and .cpp files
Exit the program only on user demand

code:
//dispays menu
void displayMenu() {
   cout << "Please Choose a calculation function" << endl;
   cout << endl;
   cout << "Enter 1 to calculate the hypotenuse of a triangle of a triangle" << endl;
   cout << endl;
   cout << "Enter 2 to calculate the area of a trapezoid" << endl;
   cout << endl;
   cout << "Enter 3 to calculate the volume of a rectangular prism" << endl;
   cout << endl;
   cout << "Enter any other letter or number input to exit" << endl;
}


//hypotenuse of triangle and associated functions
double calculateHypotenuse(double sideA, double sideB) {
   double hypotenuse = sqrt((sideA * sideA) + (sideB * sideB));
   return hypotenuse;
}
void hypotenuseMenuOption() {
   double side1;
   double side2;
   cout << "Enter the measurement of the base of the triangle" << endl;
   cin >> side1;
   cout << "Enter the measurement of the height of the triangle" << endl;
   cin >> side2;
   cout << endl;
   cout << " The hypotenuse of the triangle is: " << calculateHypotenuse(side1, side2);

}

//trapezoid area and associated functions
double calculateTrapezoidArea(double base1, double base2, double height) {
   double area = ((base1 + base2) / 2) * height;
   return area;
}

void trapezoidAreaMenuOption() {
   double b1;
   double b2;
   double h;
   cout << "Enter the first base of the trapezoid" << endl;
   cin >> b1;
   cout << "Enter the second base of the trapezoid" << endl;
   cin >> b2;
   cout << "Enter the height of the trapezoid" << endl;
   cin >> h;
   cout << endl;
   cout << "The area of the trapezoid is: " << calculateTrapezoidArea(b1, b2, h);
}

//volume of a rectangular prism and associated functions
double calculateRectangleVolume(double length, double width, double height) {
   double volume = length * width * height;
   return volume;
}

void rectangleVolumeMenuOption() {
   double rectangleLength;
   double rectangleWidth;
   double rectangleHeight;
   cout << "Enter the length of the rectangle" << endl;
   cin >> rectangleLength;
   cout << "Enter the width of the rectangle" << endl;
   cin >> rectangleWidth;
   cout << "Enter the height of the rectangle" << endl;
   cin >> rectangleHeight;
   cout << endl;
   cout << "The volume of the rectangular prism is: " << calculateRectangleVolume(rectangleLength, rectangleWidth, rectangleHeight);
}

//driver
int main() {
   displayMenu();
   int menuChoice;
   cin >> menuChoice;
   if (menuChoice == 1) {
       hypotenuseMenuOption();
   }
   else if (menuChoice == 2) {
       trapezoidAreaMenuOption();
   }
   else if (menuChoice == 3) {
       rectangleVolumeMenuOption();
   }
   else {
       exit(0);
   }
  

 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 8 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,