Question: C++ This assignment will require processing a 2 dimensional array. Review section (8th Ed - Section 7-9 starting on page 422 - 9th Ed -

C++

This assignment will require processing a 2 dimensional array.

Review section (8th Ed - Section 7-9 starting on page 422 - 9th Ed - Section 7-8 pg 424). I would recommend printing the attached document.

Using the attached document, build a program that will prompt for a gender and age and height in inches. The age range should be 0-18.

Please disregard the ages 1/4, 1/2, 3/4, 1&1/2, and 2&1/2. Start with Birth (0) and then 1 - 18.

Most of the issues around Assignment 2 are related to the defining the array. 2D arrays can be thought of as spreadsheets, with a row and column. General solutions below are :

1. Create a 2 Dimensional Array with 19 rows and 2 columns.

float growthChart[19][2] = { { 28.6, 30.9 }, { 42.2, 44.7 }, { 49.5, 52.8 }, .....

or

 float growthChart[19][2];
 growthChart[0][0] = 28.6; growthChart[0][1] = 30.9; growthChart[1][0] = 42.2; 
 The statement "float growthChart[19][2]" implies 19 rows, with 2 columns to choose from. Age is the implied row and gender can be column 0 or 1. Thus growthChart[age 0-18 ][0 or 1 for gender ] is a direct way to get to the data and does not require a loop. 2. Create a 2 Dimensional Array with 19 rows and 3 columns, age -boy% - girl%. float growthChart[19][3] = { { 0, 28.6, 30.9 }, { 1, 42.2, 44.7 }, { 2, 49.5, 52.8 }, ..... or
 float growthChart[19][3];
 growthChart[0][0] = 0; // age
 growthChart[0][1] = 28.6;
 growthChart[0][2] = 30.9;
 
 Age is column 0, and with boy % for column 1 and girl % for column 2. You could search this array with a for loop. 
 If growthChart[row][0] == age then percentage=growthChart[age - which is also the row][ gender 1 or 2] Float or Double will handle the decimal place so "int" is not correct. Remember double can "double" the amount of memory used compared to float. 

Both option 1 and 2 approaches are valid.

Option 1 appears simpler and takes advantage of the age and row always being the same index. However, this approach would completely fail if the data that was specified to be ignored needed to be added back in - (such as 3/4 or 0.75 age). By knowing the age is the row, there is no need to do a "for loop" to search.

Option 2 allows some flexibility and also clarity to this by explicitly defining the age values. Option 2 allows a serial search (for loop) if desired.

When calculating for number of feet, you can simply calculate into an int variable. Any excess is truncated by default since an int by definition contains only whole numbers.

To determine inches, consider the modulus operator - %. Your text book can direct you - it is listed in the back index under the word "Operators".

Professor Keith

Once you have obtained their growth percentage for the age, display the retrieved growth percentage and calculate and display the expected height in inches and feet+inches.

Allow this input to be entered again unless I choose to exit.

C++ This assignment will require processing a 2 dimensional array. Review section

40.1072 44.70% 48.8072 66.267 Prediction of Human Stature The table below shows the average mean percentage of mature height for both boys and girls at each age from birth to 18 years. Age in Years Boys Girls Birth 28.67 30.9% 33.97 36.0% 37.7% 39.87 42.27. 42.26% 11 45.6% 49.5% 52.87 24 51.6% 54.87 53.8% 57.007 58.0% 61.87 61.8% 65.27 70.3 69.0% 74.0% 72.07 9 75.0% 10 78.0% 11 81.17 12 84.2% 92.97 13 87.37 96.57 14 91.57 15 96.1% 99.1% 16 98.3% 99.6% 17 99.3% 100.0% 18 99.8% 100.0% Thus a boy measuring 4 ft. 6 in. (54 in.) on his ninth birthday could be expected to be: 100 54 x 72 in. or 6 ft. O in. as a man. 77.567 80.7622 84.407 88.467. 98.37 75.0 the radiation of adult

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!