Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CENSUS 2010 C++ Your job is to write a program that would help us analyze the data from 2010 census. Make sure to download counties.txt.

CENSUS 2010 C++

Your job is to write a program that would help us analyze the data from 2010 census. Make sure to download counties.txt. You will need to read this file and display a series of reports on the data. Features 1 to 4 -- each feature must be in its own function with prototypes. Make sure to send in arguments by reference where necessary.

Feature 0: Read counties.txt into 3 parallel arrays. You will see that the data file contains counties, and for each county, you have county name, state of the country and population. Make sure that your program displays an error message and exits the program if it cannot find the file counties.txt. Assume that you may have up to 5000 counties in the data file.

Feature 1: Population Report feature displays the most and least populous counties in US. It also displays the average county population.

Feature 2: Allow user to enter a population range (min and max) and then display all counties that have population within that range.

Feature 3: Two counties are similar if they have the same population and they are in the same state. Display all counties that are similar. Hint: you need a nested loop here -- loop inside loop. For each county, you need to check its similarity with every other county.

Feature 4: Find and display the state with the most population. Hint: because states are on multiple rows, we need to keep track of the state of each county. Fortunately, the counties are sorted by state. So, assume you have a variable named currState which will keep the state you are currently following. currStatePop will keep the population of this state. Also, lets keep maxState and maxStatePop variables. These will hold the state with the maximum population. Now go through each county, check if the state of the county is same as CurrState. If so, we need to add the population of this county to currStatePop. Otherwise, that means we found a county with a new state. That also means we are done with reading counties from currState. At this point currState has the state name and the currStatePop has the total population of currState. Check if currStatePop is larger than maxStatePop, if so, we need to set maxState and maxStatePop to currState and currStatePop, respectively. And then we need to set currState to the state at ith index of the for loop and currStatePop will be set to the population of the county at ith index.

Feature 0: Exit

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

Step: 3

blur-text-image

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

Sybase Database Administrators Handbook

Authors: Brian Hitchcock

1st Edition

0133574776, 978-0133574777

More Books

Students also viewed these Databases questions

Question

How would we like to see ourselves?

Answered: 1 week ago

Question

How can we visually describe our goals?

Answered: 1 week ago

Question

What metaphors might describe how we work together?

Answered: 1 week ago