C++ Project: Good Health

The United Nations (UN) has set forth 17 goals for sustainable development. Goal 3 is designed to “Ensure healthy lives and promote well-being for all at all ages.” Well-being has many different facets – physiological, psychological, and others – but all require access to resources, including medicine, education, clean water, healthy food, and education. Many parts of the world still suffer from an abundance of treatable diseases and premature mortality. One aspect of well-being involves heart health, which includes related concerns like cholesterol, blood pressure, and respiratory conditions.

In this project, we will consider heart health, blood pressure, and how to measure risk factors for potentially fatal conditions.

Heart Health

Heart health is a critical component of a sustainable and enjoyable human life. The human heart pumps and circulates blood throughout the body, so maintaining open and clear pathways (e.g. arteries) is essential to proper health. Cholesterol is one compound that can impede the body’s circulatory function. Cholesterol is found in all cells of the body, but an excess of cholesterol can have damaging effects on heart health. Individuals can maintain a healthy cholesterol level by eating a fiber-rich, low-fat diet and getting plenty of exercise, among other things. Unhealthy cholesterol levels can lead to a variety of heart-related ailments, including arteriosclerosis.

High cholesterol can lead to high blood pressure, which raises your risk of strokes or heart disease. Watch the following video to learn more about how blood pressure works in the body:

According to the CDC, about 1 in 3 Americans have high blood pressure. Individuals can maintain a reduce their risk of high blood pressure by eating a healthy diet, getting plenty of exercise, and avoiding tobacco, among other things.

Diagnosing Blood Pressure Problems

While each of us has had a reading of our blood pressure taken, many of us may not know what blood pressure actually means. Blood pressure is expressed as a ratio of the maximum (systolic) and minimum (diastolic) pressure found in the aorta during one cardiac cycle. These pressure values are measured in millimeters of mercury (mmHg). The following link may prove useful in visualizing these concepts:

Cardiac Cycle (University of Utah Medical School)
Animation showing the cardiac cycle.

Determining abnormal blood pressure is critical for diagnosing and averting a number of serious health problems (e.g. heart disease and stroke). Doctors therefore make decisions about the potential for serious health problems based on a few simple calculations. Two simple calculations of interest are pulse pressure (PP) and mean arterial pressure (MAP).

The pulse pressure of an individual can be computed as the difference between the systolic and diastolic pressures. The mean arterial pressure is the average pressure during the cardiac cycle. The MAP of a normal, resting heart can be computed by the formula:

MAP = DP + (1/3)PP

where DP is the diastolic pressure and PP is the pulse pressure.

C++ Project: Computing Blood Pressure Values

This project will provide you with an introduction to the fundamentals of problem-solving in C++. The focus of this project is on how to solve simple problems using primitive C++ data types, variables, if statements, and arithmetic operations. In this project, you will…

  • Develop code to read data from the standard input and produce data to the standard output.
  • Translate a given mathematical expression into equivalent syntactically correct programming statements.
  • Write code that conforms to a programming style specified by the instructor.
  • Select and implement the appropriate control structure(s) for this problem.

Before you begin, it is recommend that you explore the content found in the If Statements in C++ electronic resource. This resource includes code examples, exercises, video discussions of C++ concepts, and a vocabulary list.

As you write your code, be sure to properly document your code. Consult the C++ Coding Guidelines document (provided by the instructor) for style expectations. Well-written code is easier to debug, easier to maintain over time, and easier to extend as new requirements arise.

Exercise #1: Create a program called ArterialPressure.cpp in your C++ development environment. This program will ultimately compute a user’s pulse pressure and the mean arterial pressure based on two inputs: the systolic pressure (a int value) and the diastolic pressure (an int value). As a first step, add code to your program which prompts the user for the two inputs and stores them in local variables. Once the input is complete, your program should echo-print the input values and end the program.

Here are few sample tests you can run to check if your program is working correctly; your prompts should appear exactly as shown here, and you can type in the listed input values when prompted:

Test Case #1: Normal Blood Pressure

Enter your systolic pressure: 120 
Enter your diastolic pressure: 80 

You entered a pressure of 120 / 80.

Test Case #2: High Blood Pressure

Enter your systolic pressure: 170 
Enter your diastolic pressure: 110 

You entered a pressure of 170 / 110.

Exercise #2: Next, you will add code to your program to compute the pulse pressure. You will need to declare another variable (a double) to store the pulse pressure value.  Once you have used the input values to compute the pulse pressure, output the pulse pressure to the screen with a descriptive message and two digits of precision. Here are few sample tests you can run to check if your program is working correctly:

Test Case #3: Normal Blood Pressure

Enter your systolic pressure: 120 
Enter your diastolic pressure: 80 

You entered a pressure of 120 / 80.
Your pulse pressure is: 40.00. 

Test Case #4: High Blood Pressure

Enter your systolic pressure: 170 
Enter your diastolic pressure: 110 

You entered a pressure of 170 / 110.
Your pulse pressure is: 60.00. 

Exercise #3: Next, you will add code to your program to detect a “high” pulse pressure. If the pulse pressure is greater than 80 mmHg, inform the user that their pulse pressure is high. Use a simple if statement (no else clause). Here are few sample tests you can run to check if your program is working correctly:

Test Case #5: Normal Blood Pressure

Enter your systolic pressure: 120 
Enter your diastolic pressure: 80 

You entered a pressure of 120 / 80.
Your pulse pressure is: 40.00. 

Test Case #6: High Pulse Pressure

Enter your systolic pressure: 170 
Enter your diastolic pressure: 80 

You entered a pressure of 170 / 80.
Your pulse pressure is: 90.00. 
Your pulse pressure is high. 

Exercise #4: Add code to your program to compute and display the mean arterial pressure, using the previously provided formula. You will need to declare another variable (a double) to store the mean arterial pressure value. The mean arterial pressure should be output to the screen with two digits of precision. Beware of integer division! Here are few sample tests you can run to check if your program is working correctly:

Test Case #7: Normal Blood Pressure

Enter your systolic pressure: 120 
Enter your diastolic pressure: 80 

You entered a pressure of 120 / 80.
Your pulse pressure is: 40.00.
Your mean arterial pressure is: 93.33. 

Test Case #8: High Blood Pressure

Enter your systolic pressure: 170 
Enter your diastolic pressure: 110 

You entered a pressure of 170 / 110.
Your pulse pressure is: 60.00. 
Your mean arterial pressure is: 130.00. 

Exercise #5: Finally, add code to your program to determine whether the mean arterial pressure reading is acceptable. If the mean arterial pressure is below 60 mmHg, alert the user that he or she should seek medical assistance; else, inform the user that their mean arterial pressure is within acceptable limits. Use an if-else statement. Here are few sample tests you can run to check if your program is working correctly:

Test Case #9: Normal Blood Pressure

Enter your systolic pressure: 120 
Enter your diastolic pressure: 80 

You entered a pressure of 120 / 80.
Your pulse pressure is: 40.00. 
Your mean arterial pressure is: 93.33. 
Your mean arterial pressure is within acceptable limits.

Test Case #10: High Blood Pressure

Enter your systolic pressure: 170 
Enter your diastolic pressure: 110 

You entered a pressure of 170 / 110.
Your pulse pressure is: 60.00. 
Your mean arterial pressure is: 130.00. 
Your mean arterial pressure is within acceptable limits. 

Test Case #11: High Pulse Pressure

Enter your systolic pressure: 170 
Enter your diastolic pressure: 80 

You entered a pressure of 170 / 80.
Your pulse pressure is: 90.00. 
Your pulse pressure is high. 
Your mean arterial pressure is: 110.00. 
Your mean arterial pressure is within acceptable limits. 

Test Case #12: Low Mean Arterial Pressure

Enter your systolic pressure: 80 
Enter your diastolic pressure: 40 

You entered a pressure of 80 / 40.
Your pulse pressure is: 40.00. 
Your mean arterial pressure is: 53.33. 
You should seek medical assistance. 

Your program is now complete.

Deliverables

See the instructor for submission instructions and due date(s).

Powered by WordPress. Designed by WooThemes

Skip to toolbar