Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this question, you will be designing a modular program using a structure chart.Show parameter passing (flow of data) on your structure chart.The design is

  1. For this question, you will be designing a modular program using a structure chart.Show parameter passing (flow of data) on your structure chart.The design is then implemented as a modular C program. There are no marks for the C program if any global data is used. The structure chart can be drawn by hand, and a phone camera used to capture the image and inserted into this document. Make sure that the image is clear, and text is readable otherwise no marks will be awarded.

Design and implement in C, a modular program to calculate the Body Mass Index (BMI) and Cardiovascular Disease (CVD) risk of men and women over the age of 18.

Data comes from a file called data.txt. A sample data file is provided. The first number in the data file shows how many people are in the data file. So, in the sample data file, there are 3 people: John, Achmed and Schtaren. Each person has their age, weight (kg), height (m) and waist circumference (cm) on the same line. So, in the example:

John 19 64 1.65 81.2

John is 19 years old; his weight is 64 kg; his height is 1.65 m and waist circumference (WC) is 81.2 cm

Your program will calculate BMI using the following formula only if the person is over 18:

BMI = weight / (height * height)

For John, it is 64 / (1.65*1.65)

BMI is calculated to one decimal place, so John's BMI is 23.5.

Assume CVD risk = 0.68 * BMI + 0.32 * WC for everyone over 18 to simply program logic. This formula is an oversimplification used only for the purposes of the exam question.

So, John's CVD risk is 0.68 * 23.5 + 0.32 * 81.2 = 41.964. When expressed to one decimal place, it is 42.0

Your program reads the data into your data structure which is an array of records (C struct). Once the data is read in, your program closes the data file. There are no marks for this question if you use any other approach to structuring your data.

Once the file is closed, your program calculates the BMI of each person over the age of 18. Then the name, age and BMI is printed to the screen with the following advice that is found at https://www.betterhealth.vic.gov.au/tools/body-mass-index-calculator-for-adult

Advice to give when the BMI is:

  • Under 18.5 - you are very underweight and possibly malnourished.
  • 18.5 to 24.9 - you have a healthy weight range for young and middle-aged adults.
  • 25.0 to 29.9 - you are overweight
  • Over 30 - you are obese

What is "middle-aged" is not defined, so all adults above 18 will one of the above advice.

So, your program output for John will be:

John 19, BMI:23.5 - you have a healthy weight range for young and middle-aged adults. CVD risk is 42.0

As Achmed is below 18, Achmed's output is:

Achmed 12: Under 18, BMI and CVD not calculated

Each person will have their output as indicated above, one per line on the screen.

There can be any number of people in the data file. There can be people with the same name, and you can assume they are different people. Currently the first value is 3, it could be 3000 or any other positive number. You can assume that it would not be zero (0).

-------------------------Start: Structure Chart------------------

------------------End: Structure Chart---(15 marks)

Build, run and test your program in the Q3 folder. Copy the source code of the program into your answer below. The Q3 folder would also need to be submitted.

-------------------------Start: Complete C program------------------

------------------End: Complete C program---(30 marks)

'data' file content:

3 John 19 64 1.65 81.2 Achmed 12 35 1.4 50.8 Schtaren 20 90 1.7 101.6

(please give answer in modular way and c++)

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_2

Step: 3

blur-text-image_3

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions