Question: home / study / engineering / computer science / computer science questions and answers / This program should be written in C++.the united nations provided
home / study / engineering / computer science / computer science questions and answers / This program should be written in C++.the united nations provided 2009 marital status of men and women in the us (http://data.un.org/documentdata.aspx?id=322)....
Question: The United Nations provided 2009 Marital Status of Men and Women in the US (http://data.un.org/...
The United Nations provided 2009 Marital Status of Men and Women in the US (http://data.un.org/DocumentData.aspx?id=322).
Write a program to analyze the marital status of the combined total of men and women in the US. The categories being analyzed is as follows:
Single Men
Married Men
Widowed Men
Divorced Men
Separated Men
Single Women
Married Women
Widowed Women
Divorced Women
Separated Women
The program first reads headings, categories and the statistics from the file and saves them into three arrays:
Create a one-dimensional string array of the tableHeadings.
Create a one-dimensional string array Categories to store the different categories.
Create a (parallel) two-dimensional double array CatPerc to store percentage in each category. This array has 11 columns of the percentages in each age group.
The program then retrieves the percentages from the array CalcPerc, calculates average percentage of the combined men and women in each category. (Ignore age range 60-64 in calculation)
i.e. (Single Men Average + Single Women Average)/2.0
where Single Men Average = (Sum of Single Men Percentages) / 11.0 and Single Women Average = (Sum of Single Women Average)/2.0 .
Use the table below to assign the representation code to each combined men and women average in each combined category.
| Average | Representation Code |
| >=40 | H - High |
| >= 25 | N - Normal |
| < 25 | L - Low |
The program must contain at least the following functions:
(1) A function read_data to read and store data into tableHeadings, categories and calcPerc arrays.
(2) A function analyze_stats to calculate the combined men and women averages, determine the Representation Code, get the number of High, Normal and Low Representation Codes, find the highest and lowest average of all combined categories.
(3) A function display_results to display the results.
MaritalStatus2009Survey.txt
United States of America Sex MaritalStatus 15-19 20-24 25-29 30-34 35-39 40-44 45-49 50-54 55-59 60-64 65+ Men Single 98.5 87.0 61.1 35.0 22.5 18.4 17.0 12.5 7.9 0.0 4.4 Men Married 0.8 11.0 34.1 56.6 65.2 66.1 65.6 69.3 74.0 0.0 73.2 Men Widowed 0.1 0.0 0.0 0.0 0.2 0.5 0.9 1.2 2.3 0.0 12.9 Men Divorced 0.1 0.8 3.1 6.1 9.2 12.4 14.1 14.5 13.7 0.0 8.3 Men Separated 0.5 1.2 1.7 2.3 2.9 2.7 2.4 2.5 2.1 0.0 1.2 Women Single 97.2 77.4 46.3 26.3 16.4 13.1 11.5 10.0 7.1 0.0 4.0 Women Married 1.7 18.8 45.5 61.9 67.0 67.5 65.6 65.4 65.2 0.0 43.0 Women Widowed 0.1 0.3 0.3 0.6 1.1 1.4 2.8 3.8 8.2 0.0 41.3 Women Divorced 0.2 1.5 5.1 8.0 11.4 13.7 16.6 17.4 17.4 0.0 10.7 Women Separated 0.8 2.0 2.9 3.3 4.2 4.2 3.5 3.4 2.1 0.0 1.1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
