Implement a program that utilizes multiple inheritance to assess John's health. Create classes BMI (with weight and height as attributes) and BloodPressure (with systolic and diastolic pressures as attributes) to compute health metrics.In the Health class, inherit from both classes BMI and BloodPressure to provide an integrated health assessment. Input John's weight, height, systolic, and diastolic values and determine his health status.Note: BMI = Weight / (height * height)Input format :The first line consists of a positive double value representing the individual's weight in kilograms.The second consists of a positive double value representing the height in meters.The third line consists of a positive integer value representing the systolic blood pressure measurement.The fourth line consists of a positive integer value representing the diastolic blood pressure measurement.Output format :The output displays the overall health status, which can be one of the following:"Underweight with Low Blood Pressure" when BMI < 18.5, systolic < 90 and diastolic < 60."Healthy Weight with Normal Blood Pressure" when BMI is between 18.5 and 24.9 (exclusive), systolic is between 90 and 120, and diastolic is between 60 and 80."Overweight with High Blood Pressure" when BMI is between 25.0 and 29.9 (exclusive) and systolic and diastolic are both higher than 120 and 80, respectively."Health Risk Undefined" for any other conditions.Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:10.0 ≤ Weight ≤ 200.00.5 ≤ Height ≤ 2.570 ≤ Systolic blood pressure ≤ 20040 ≤ Diastolic blood pressure ≤ 150Sample test cases :Input 1 :48.01.658050Output 1 :Underweight with Low Blood PressureInput 2 :70.01.7511575Output 2 :Healthy Weight with Normal Blood PressureInput 3 :90.01.7013590Output 3 :Health Risk Undefined
Question
Implement a program that utilizes multiple inheritance to assess John's health. Create classes BMI (with weight and height as attributes) and BloodPressure (with systolic and diastolic pressures as attributes) to compute health metrics.In the Health class, inherit from both classes BMI and BloodPressure to provide an integrated health assessment. Input John's weight, height, systolic, and diastolic values and determine his health status.Note: BMI = Weight / (height * height)Input format :The first line consists of a positive double value representing the individual's weight in kilograms.The second consists of a positive double value representing the height in meters.The third line consists of a positive integer value representing the systolic blood pressure measurement.The fourth line consists of a positive integer value representing the diastolic blood pressure measurement.Output format :The output displays the overall health status, which can be one of the following:"Underweight with Low Blood Pressure" when BMI < 18.5, systolic < 90 and diastolic < 60."Healthy Weight with Normal Blood Pressure" when BMI is between 18.5 and 24.9 (exclusive), systolic is between 90 and 120, and diastolic is between 60 and 80."Overweight with High Blood Pressure" when BMI is between 25.0 and 29.9 (exclusive) and systolic and diastolic are both higher than 120 and 80, respectively."Health Risk Undefined" for any other conditions.Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:10.0 ≤ Weight ≤ 200.00.5 ≤ Height ≤ 2.570 ≤ Systolic blood pressure ≤ 20040 ≤ Diastolic blood pressure ≤ 150Sample test cases :Input 1 :48.01.658050Output 1 :Underweight with Low Blood PressureInput 2 :70.01.7511575Output 2 :Healthy Weight with Normal Blood PressureInput 3 :90.01.7013590Output 3 :Health Risk Undefined
Solution
To implement the program, we will create three classes: BMI, BloodPressure, and Health. The BMI class will have weight and height as attributes, the BloodPressure class will have systolic and diastolic pressures as attributes, and the Health class will inherit from both BMI and BloodPressure.
-
Create the BMI class:
- Define the class BMI.
- Add the constructor method that takes weight and height as parameters and initializes the attributes.
- Add a method to calculate the BMI using the formula BMI = weight / (height * height).
-
Create the BloodPressure class:
- Define the class BloodPressure.
- Add the constructor method that takes systolic and diastolic pressures as parameters and initializes the attributes.
-
Create the Health class:
- Define the class Health and inherit from both BMI and BloodPressure.
- Add the constructor method that takes weight, height, systolic, and diastolic values as parameters and initializes the attributes using the parent class constructors.
- Add a method to assess the overall health status based on the given conditions:
- If BMI < 18.5, systolic < 90, and diastolic < 60, output "Underweight with Low Blood Pressure".
- If BMI is between 18.5 and 24.9 (exclusive), systolic is between 90 and 120, and diastolic is between 60 and 80, output "Healthy Weight with Normal Blood Pressure".
- If BMI is between 25.0 and 29.9 (exclusive), and systolic and diastolic are both higher than 120 and 80, respectively, output "Overweight with High Blood Pressure".
- For any other conditions, output "Health Risk Undefined".
-
Read the input values:
- Read the weight, height, systolic, and diastolic values from the input.
-
Create an instance of the Health class:
- Create an instance of the Health class using the input values.
-
Determine the health status:
- Call the method in the Health class to assess the overall health status.
-
Display the output:
- Print the overall health status.
-
Test the program:
- Test the program with the provided sample test cases to verify its correctness.
Note: Make sure to handle any input constraints mentioned in the problem statement, such as checking the validity of the input values.
Similar Questions
John is a fitness trainer and needs to calculate the Body Mass Index (BMI) for his clients to assess their health status. Write a program for him that takes the weight in kilograms and height in meters of a client as input, calculates their BMI, and determines if they fall within the healthy range.Note: The healthy range of BMI is 18.5 to 24.9 (both inclusive).Input format :The input consists of two double values: the weight in kilograms and the height in meters.Output format :The first line of output prints "BMI: X" where X is a double value, rounded off to two decimal places.The second line prints one of the following:If the BMI is within the valid range, print "Healthy Range".Otherwise, print "Not in Healthy Range".Refer to the sample output for formatting specificationsCode constraints :10.0 ≤ weight ≤ 300.00.00 ≤ height ≤ 3.00Sample test cases :Input 1 :65.81.75Output 1 :BMI: 21.49Healthy RangeInput 2 :124.31.87Output 2 :BMI: 35.55Not in Healthy Range
Consider you are working in the Hospital and find the Obesity of outpatients, which you need to check Body Mass Index (BMI) for each customer and BMI is found by taking your weight in kilograms and dividing by the square of your height in meters. The BMI categories are:• Under weight: <18.5• Normal weight: 18.5–24.9• Over weight: 25–29.9• Obesity: BMI of 30 or greaterUse class, object, constructor, attributes, and methods.( 1 inch=2.5 cm) Testcase Input 1:Raja5564.96OutputNormal weight
Single File Programming QuestionProblem StatementBalaji wants your help to design a fitness calculator. The simple measure of body fitness is the BMI or Body Mass Index. It depends only on the height L and weight W of a person. It is defined as BMI = [weight / height2] where weight is taken in kilograms and length in meters. Four general grades are proposed:Underweight[U] - when BMI < 18.5Normal weight[N] - 18.5 <= BMI < 25.0Heavyweight [H] - 25.0 <= BMI < 30.0Overweight [O] - above or equal to 30.0Write a program that takes in the Weight (in Kg) and Length (in meters) of an individual and displays the grade as U, N, H, O.Note: Store all the variables in register memory.Input format :The first line of input consists of an integer, representing the weight.The second line consists of a double value, representing the height in meters.Output format :The output displays the grade based on the given conditions.Refer to the sample output for the formatting specifications.Code constraints :In the given scenario, the test cases will fall under the following constraints:60 ≤ weight ≤ 2001.0 ≤ height ≤ 5.0Sample test cases :Input 1 :1303.5Output 1 :UInput 2 :2002.7Output 2 :HInput 3 :902.1Output 3 :NInput 4 :741.3Output 4 :O
BMI CalculatorCreate an application which calculates BMI (Body Mass Index)Your app should have 2 input boxesTake weight in kgs from userTake height in meters from userBased on entered height and weight calculate BMI of that personHere is the formula for manually calculating BMI BMI = (weight) / (height * height)From the obtained BMI result, display whether the person isUnderWeight - bmi <= 18.4Normal Weight - bmi >= 18.5 && bmi <= 24.9Overweight - bmi >= 25 && bmi <= 29.9Obese - bmi >= 30Hint: use If conditionsSample Output
Create a function of name get_bmi() that receive the weight in kilograms and height in centimeter of a person and return his or her Body Mass index (BMI). The function should convert the height to meters before calculating the BMI.Height in meter = height in centimeter / 100BMI = weight in kilogram / (height in meter * height in meter)For example:Test Resultprint("BMI value:", round(get_bmi(60, 160),1))BMI value: 23.4print("BMI value:", round(get_bmi(85, 170),1))BMI value: 29.4
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.