Question: ASSIGNMENT 2 Total (70) QUESTION 1: (20) BMI or Body Mass Index is a method of estimating a person's body fat levels based on a
ASSIGNMENT 2 Total (70)
QUESTION 1: (20)
BMI or Body Mass Index is a method of estimating a person's body fat levels based on a person's weight and height measurement. The BMI is calculated by dividing the persons body mass/weight (in kilograms) by the square of the body height (in metres). The result is universally expressed in units of kg/m2.
BMI formula: BMI = weight /(height)2
| BMI | Weight status |
| Below 18.5 | Underweight |
| 18.524.9 | Healthy |
| 25.029.9 | Overweight |
| 30.0 and above | Obese |
Write a program that calculates a persons BMI and displays the weight status according to the BMI value, indicating whether the person is underweight, healthy, overweight or obese. The BMI weight statuses and related values are listed in the above table.
The program should have the following functions:
1.1. getData that prompts and returns their weight and height; (5)
1.2. calcBMI to calculate the BMI ; (5)
1.3. displayFitnessResults to display the BMI and relevant weight status message; (5)
1.4. main function (5)
You have to submit the program code and output.
QUESTION 2: (40)
Suppose we want to compile a student academic report for a high school learner in grade 12 (matric).
A matric learner is enrolled for 6 study units (subjects), namely: English, Mathematics, Life Orientation, History, Computer literacy, Geography. The learner has to pass at least four subjects, including English, to complete grade 12. The subject pass mark is 50%.
Write a program that prompts the learner to key in their marks for each subject. The program should include the following functions:
A function studentDetails, that prompts the learner to key in their personal details
name,surname, and schoolName. (3)
A function getMarks, that prompts the learner to key in a mark for each of the six subjects, and validate the marks. Do not accept marks lower than 0 or higher than 100. (3)
A function calcAverageYearMark, to calculate and display the average of the 6 Subjects. This function should be called just once by main, and should be passed the 6 Subject marks. (6)
A function minMax, to find and return the lowest and the highest of the 6 subject marks
passed to it as the subject with the lowest mark; (6)
A function passOrFail, to determine whether the student has passed or failed grade 12. (9)
A function awardDistinction to determine which of the subjects have received distinctions. A subject receives a distinction if the mark is 75% and above. Also a student has
passed with distinction if the average mark is 75% and above. (3)
A function codeSymbol, to convert each mark to a symbol (A, B, C, D, E, F) and a code
(7,6,5,4,3,2,1). The symbol and code should be printed next to the mark in the student report.
The same should be calculated and displayed for the average mark. (6)
A function to Display the student report. (4)
Use the table below to determine the student symbol and code attained.
| CODE | SYMBOL | MARK |
| 7 | A | 80 - 100% |
| 6 | B | 70 - 79% |
| 5 | C | 60 - 69% |
| 4 | D | 50 - 59% |
| 3 | E | 40 - 49% |
| 2 | F | 30 - 39% |
| 1 | FF | 0 - 29% |
Execute your program using the following data:
|
| John Africa (Kings College) | Mary Smith (Green valley High) | Thuli Booi (Gauteng girls ) |
| English | 50% | 48% | 82% |
| Mathematics | 76% | 80% | 66% |
| Life Orientation | 40% | 75% | 62% |
| History | 62% | 70% | 76% |
| Computer literacy | 56% | 86% | 86% |
| Art | 38% | 72% | 78% |
You have to submit the program code and output.
Sample run:
Please key in your name:
John Africa
Please key in the name of your school:
Kings College
Key in your mark for English:
50
Key in your mark for Mathematics:
76
Key in your mark for Life Orientation:
40
Key in your mark for History:
62
Key in your mark for Computer literacy:
56
Key in your mark for Art:
38
***********************************************
**** STUDENT ACADEMIC RECORD
This program inputs the learner marks of matric level subjects and prints the student final report.
***********************************************
****
Name: John Africa School: Kings College
| Subject Mark | Symbol Code |
| English 50% | D 4 |
| Mathematics 76% | B 6 |
| Life Orientation 40% | E 3 |
| History 62% | C 5 |
| Computer literacy 56% | D 4 |
| Art 38% | F 2 |
Average Year Mark: 53.67 with Symbol D and code 4
Outcome: Passed
The highest mark was 76%
The lowest mark was 38%
***************************************************
| QUESTION 3: |
|
|
|
|
|
|
|
| (10) |
Draw variable diagrams for the following program with input values 2 (for variable first) and 3 (for variable second).
Note : Refer to Lesson 23 of the Study Guide and go through the activities to figure out how the execution flows in a program like this where the main() calls other functions. Follow the conventions specified in the Study Guide when you draw the variable diagrams.
For instance:
A ? shows an uninitialized value for a variable.
The notation 25 5 means that execution jumps from line 25 to line 5.
We use square brackets [ ] around the name of a variable to show that it is inaccessible while the current function is being executed.
#include
using namespace std;
3
void multiplyBy2(int firstP, int secondP)
{
firstP = firstP * 2;
secondP = secondP * 2;
}
9
void multiplyBy3(int & firstP, int & secondP)
{
12
firstP = firstP * 3;
secondP = secondP * 3;
}
16
int main()
{
int first, second;
cout << "Enter the first number: "<< endl;
cin >> first;
cout << "Enter the second number:" << endl;
cin >> second;
multiplyBy2(first, second); 25 multiplyBy3(first, second);
cout << "The first number is "<< first << " now." << endl;
cout << "The second number is " << second << " now." << endl;
28
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
