Question: In c++ Please. Now take your Project 4 and modify it. Youre going to add another class for getting the users name. Inherit it. Be

In c++ Please.

Now take your Project 4 and modify it. Youre going to add another class for getting the users name. Inherit it. Be sure to have a print function in the base class that you can use and redefine in the derived class. Youre going to also split the project into three files. One (.h) file for the class definitions, both of them. The class implementation file which has the member function definitions. And the main project file where your main function resides. Dont forget to display it when you display the answers.

Project 4 You are going to convert feet and inches or pounds in this program. You will give the user the choice of converting feet and inches to centimeters or pounds to kilograms. With the correct answer you will also display the number entered. Create a menu for the user. Give them the opportunity to convert either as many times as they want, but they must convert at least once. Add a class and place your private data members in it as well as the member functions for conversion. Not the menu function. Remember the class should be focused around one thing and that is the conversion.

formulas:

feet

=

cm div 30.48

inches

=

(cm mod 30.48) / 2.54

lbs

=

kg / 0.45359

cm

=

(feet * 30.48) + (inches * 2.54)

kg

=

lbs * 0.45359

Please note: div ist the division without remainder whereas mod returns the remainder. For instance: 7 divided by 3 equals 2 remainder 1 and therefore 7 div 3 = 2 and 7 mod 3 = 1

units:

1 foot

=

30.48 cm

1 inch

=

2.54 cm

1 lbs

=

0.45359 kg

1 cm

=

0.3937 inches

1 kg

=

2.2046 lbs

My coding from project 4 :-

#include

using namespace std;

class Conversion

{

public:

double feetInchesToCms(double feetInches)

{

return feetInches*30.48;

}

double poundsToKgs(double pounds)

{

return pounds*0.45359;

}

};

int main()

{

int choice;

while (true)

{

cout << " -- Menu --" << endl;

cout << "1.Feet Inches to Cms" << endl;

cout << "2.Pounds to Kgs" << endl;

cout << "3.Quit" << endl;

cout << "Enter Choice of Conversion :";

cin >> choice;

switch (choice)

{

case 1: {

double feetInches;

Conversion c;

cout << "Enter Feet Inches:";

cin >> feetInches;

cout << feetInches << " feet Inches are " << c.feetInchesToCms(feetInches) << " cms." << endl;

continue;

}

case 2: {

double pounds;

Conversion c;

cout << "Enter Pounds :";

cin >> pounds;

cout << pounds << " pounds are " << c.poundsToKgs(pounds) << " kgs." << endl;

continue;

}

case 3: {

break;

}

default: {

cout << "Invalid Choice." << endl;

continue;

}

}

break;

}

return 0;

}

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!