Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a complete C++ program that contains a class called Person. 1. The class should have seven (7) private member variables (attributes) to hold a

image text in transcribedimage text in transcribedimage text in transcribed

Write a complete C++ program that contains a class called Person. 1. The class should have seven (7) private member variables (attributes) to hold a name, National Registration Identity Card (NRIC) number that has 12-digit numbers, height in centimeter (cm), weight in kilogram (kg), activity level, Basal Metabolic Rate (BMR), and calorie. Note: You must create the object of string class to store hold the NRIC number. 2. The class should have the following public member functions: - A constructor with default arguments that assign the values of name, height, weight and activity level member variables with the passed arguments. The constructor also enables to assign empty string (**) to the name and NRIC member variables, zero (0.0) to the height and weight member variables and zero (0) to the activity level member variable. A getName function that returns the value of name member variable. - A getGender function that returns the string value of gender. The gender will be determined by the last digit of NRIC number. If the last digit is odd number, then the gender of the Person's object is male; otherwise gender of the Person's object is female Example: NRIC number is 980203041527. The last digit is 7. It is an odd number Therefore, the gender of Person's object is male. A getAge function that returns the integer value of age. The age will be determined by the first two digits of NRIC number. Example: NRIC number is 980203041527. The first two digits are 98, meaning the Person's object was born in 1998. His/her age is 22. **Note: You must use an appropriate function(s) in string class to determine the age and gender of Person's object. A caleCalorie function that calculates the value of BMR and calorie member variables with gender and age as the arguments. i) First step is to calculate the value of BMR variable according to the following Mifflin - St Jeor equation formula: o Formula for male: BMR = (10 x weight) + (6.25 x height) - (5 x age) +5, where weight is in kilogram (kg), height in centimeter (cm) and age in year. Formula for female: BMR = (10 x weight) + (6.25 x height) (5 x age) - 161, where weight is in kilogram (kg), height in centimeter (cm) and age in year. ii) Second step is to calculate the value of calorie variable from the BMR result in the first step and based on the activity level according to the following table: Activity Level Sedentary Calorie BMR x 1.2 Lightly Active Calorie BMR X 1.375 Moderately Active Calorie BMR X 1.55 Very Active Calorie = BMR x 1.725 Extra Active Calorie - BMR x 1.9 Formula A readInput function that reads the values from the keyboard for name, NRIC, height weight and activity level member variables. For activity level, the input value is according to the following table: Activity Level Input Sedentary Lightly Active Moderately Active Very Active Extra Active 1 2 3 4 5 **Note: It is also need to invoke getGender, getAge and caleCalorie function to obtain the value of calorie. - An overloaded equality (--) operator that determines if two objects have the same activity level, then return true; otherwise return false. 3. The class should also have the following friend of standalone functions: - A dispInfo function to display the age and gender of Person's object in the following format (please refer to the sample output given in Figure 1): Your gender is ????? Your age is ++ year old - An overloaded output (

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 Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions

Question

List all of the specific items in the forfeiture.

Answered: 1 week ago

Question

Which of these influenced your life most dramatically?

Answered: 1 week ago

Question

What roles have these individuals played in your life?

Answered: 1 week ago