2D arrays

Can anyone guide me with this please?


1. Array uses and notation
Review the material presented in the slides of Section 2.13
2. Reading data into an array
Create a new folder in your exercise folder called Exercise2_13.
Copy your program census.cpp from your Exercise2_11 folder to the Exercise2_13 folder, and rename it census_2D.cpp. Also copy the text file statistics.txt to Exercise2_13 by clicking on the file name.
You are to modify your previous program that used a single-indexed array name age[10 ] to use two double-indexed integer arrays data[10][3] and name[10][6]. The census_2D.cpp program will read from a text file statistics.txt the name, ages, and height of a group of 10 people. Since the data file has three lines of text preceding the data, you must use getline to skip those lines and access the data. The order of the data, as the file shows, is a name (6 letters or less), the age in years, and the height as two separated integer numbers, feet then inches. Once you have skipped the three text lines, the program will use a loop to read in all the rows of data. For each row of data the program will read the name into the char array name[n], where n is the number of the row (i.e., 0, 1, 2, etc.). It then will read the age into data[n][0], the height feet into data[n][1], and the height inches into data[n][2]. The loop will continue to read in data until all ten rows are read.
3. Performing calculations
After the data is entered, the main program will call two single result functions int tallest(data[10][3]) and int oldest(data[10][3]), which will transfer the data[ ] [ ] array in the argument, and return to the main program the number of (a) the tallest person and (b) the oldest person. The decimal height in feet is then determined by calling a void function void height(int[10][3], double[10]), which passes data[ ] [ ] as an argument and returns the height in decimal feet as the array ft[ ] (e.g., 5 feet and 4 inches would print as 5.333 feet). The main program will then echo print to a file a four-column, formatted table of the data and results, with column 1 the name, column 2 the age in years, and column 3 the height as a decimal number of feet. Column 4 will indicate whether the person in that row is the tallest or the oldest by printing "tallest" or "oldest" in the appropriate row; otherwise, that column will be left blank.
4. Run other examples
Run the three other examples from Section 2.13 to see other uses of double-indexed arrays.
Copyright © 2009 by Pearson Education, Inc., Upper Saddle River, New Jersey, 07458. Pearson Prentice Hall. All rights reserved.

We don't do homework here but maybe this will help.
http://www.cprogramming.com/tutorial/lesson8.html
Topic archived. No new replies allowed.