Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Define a C++ class in a file person.h with the following declarations: #include #include #include using namespace std; class person { private: string name;

1. Define a C++ class in a file person.h with the following declarations:

#include

#include

#include

using namespace std;

class person

{

private:

string name;

int feet;

int inches;

int weight;

public:

person ();

void input ();

void grow (int i);

void shrink (int i);

void gain (int w);

void lose (int w);

void print ();

};

The private data represents a persons name, height measured in feet and inches and weight measured in pounds.

The public methods are:

person: Constructor that sets name equal to Unassigned and integer values equal to zero.

input: Prompts the user for name, feet, inches and weight and sets the private data values to these user entered values. Checks for negative values for feet, inches, and weight and for inches greater than 11. If any of these error conditions occurs, an error message should be printed and no values should be set.

grow: Increases the persons height by the given number of inches. Feet and inches should be correctly set based on the increase. If the given number of inches is negative, an error message should be printed and the values not changed.

shrink: Decreases the persons height by the given number of inches. Feet and inches should be correctly set based on the decrease. If the given number of inches is negative, an error message should be printed and the values not changed. If the decrease in inches gives a total height value less than 1 inch, an error message should be printed and the values not changed.

gain: Increases the persons weight by the given weight. If the given weight is negative, an error message should be printed and the values not changed.

lose: Decreases the persons weight by the given weight. If the given weight is negative, an error message should be printed and the values not changed. If the decrease in weight gives a total weight value less than 1 pound, an error message should be printed and the values not changed.

print: Prints the name, height and weight with labels and nice formatting. It also computes and prints the persons body mass index, BMI. The formula for this is:

BMI = weight * 703

------------

inches2 (Note: this is total height in inches squared)

The BMI should be printed with two places after the decimal. See the example for the format the output should follow.

2. Write a personapp.cpp application program that utilizes the person object. It should be menu driven with choices for inputting a persons statistics, growing, shrinking, gaining weight, losing weight, printing the persons statistics and quitting.

The menu printed should be:

Enter one of the following:

e: Enter a persons's statistics

g: Grow by a number of inches

s: Shrink by a number of inches

i: Increase in weight

d: Decrease in weight

p: Print the current statistics

q: Quit the program

There is a lengthy sample output of the program on Blackboard. The values, text, and spacing of your program should closely follow that example.

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

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

Discuss how to use job evaluation to build job structures.

Answered: 1 week ago

Question

Describe the factors influencing of performance appraisal.

Answered: 1 week ago

Question

What is quality of work life ?

Answered: 1 week ago

Question

Which team solution is more likely to be pursued and why?

Answered: 1 week ago