Question

C++ ONLY The question is - The US Census Bureau gathers population information and aggregates it...

C++ ONLY

The question is -

The US Census Bureau gathers population information and aggregates it at the city, county and state level. A research project on population distribution in the Southeast US has acquired a data file from the Census Bureau that contains the populations of each county in Mississippi (MS) and Florida (FL). For this research project write a program that calculates the average county population for these two states.

Each line in the Census Bureau data file has the following structure

NJ Burlington 451336

The first field (starting at the first character) contains the two letter code for the state. The second field is the name of the county, and the third field is the 2010 population. The fields are separated by a single tab character. The input data lines are in no particular state order. Don't make any assumptions about the number of lines in the file. A data file for testing your program can be found here.

Write a program that asks the user for the input file's name. Open the file and read each line. Sum and average the appropriate values. Once all of the input lines are read, write out the average county population for each state, both to the console and to an output file. Format your output so that a user can understand the meaning of the calculation, i.e. don't just output "state average". The average value should also be formatted to have 1 decimal place using the fixed decimal format. So you should perform floating point arithmetic operations. Your program should have the following functions:

A function that opens the input and output files and sets the output of the floating-point number to one decimal place in a fixed decimal format.

A function that initializes the variables needed in the main program. (hint: you will need to use pass by reference in this function.)

A function that adds a county population to the current sum for a state.

A function that calculates the average county population for a state. (hint: this function should return a floating point value.)

A function that outputs the relevant results to the console and into the output file.

Do not use global variables in this program. Use the appropriate parameters to pass information in and out of the functions.

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
C++ ONLY The question is - The US Census Bureau gathers population information and aggregates it...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • The Census Bureau groups data on households into census tracts, where each census tract has a total population of about 4,000 residents. Census tracts should be divided so that the households in the c...

    The Census Bureau groups data on households into census tracts, where each census tract has a total population of about 4,000 residents. Census tracts should be divided so that the households in the census tracts share certain characteristics, such as economic status. Even though most tracts are around 4,000 residents, there is some variability, which is the focus of this lab. In practice, census tracts usually have a population between 1,200 and 8,000 people. I just need help with the...

  • Using C++. Please Provide 4 Test Cases. Test # Valid / Invalid Data Description of test...

    Using C++. Please Provide 4 Test Cases. Test # Valid / Invalid Data Description of test Input Value Actual Output Test Pass / Fail 1 Valid Pass 2 Valid Pass 3 Valid Pass 4 Valid Pass Question 2 Consider a file with the following student information: John Smith 99 Sarah Johnson 85 Jim Robinson 70 Mary Anderson 100 Michael Jackson 92 Each line in the file contains the first name, last name, and test score of a student. Write a...

  • C++ 3. Write a program that reads integers from a file, sums the values and calculates...

    C++ 3. Write a program that reads integers from a file, sums the values and calculates the average. a. Write a value-returning function that opens an input file named in File txt. You may "hard-code" the file name, i.e., you do not need to ask the user for the file name. The function should check the file state of the input file and return a value indicating success or failure. Main should check the returned value and if the file...

  • Problem Statement You are to create a Visual Basic(VB) project for a census bureau to obtain...

    Problem Statement You are to create a Visual Basic(VB) project for a census bureau to obtain and analyze household income survey data within the Pittsburgh   area (including Morgantown Ky). Data Collected: Home identification code (4 alphanumeric characters) – required Program should generate it using a random number generator. You won’t use this anywhere it just need to be generated. Generate the first number in the Form Load event and then each subsequent number in the button click. See attached code...

  • Description Write C++ code that correctly input and output information. (Moving data to and from the...

    Description Write C++ code that correctly input and output information. (Moving data to and from the screen and to and from text files. Also inputting predefined functions, etc., from included libraries.) Problem Description Consider a data file that has geometrical angle values in degrees. Angle values may be on one line, several lines, or any other white space separated format. Fig. 1 below shows one possible format, but other formats are possible. 12.9 100.8 270.5 300.6 120.8 There are no...

  • C++. You are working for the census bureau and you need to write a program to...

    C++. You are working for the census bureau and you need to write a program to do the following: A). Count the number of people in each of the following age groups: 0-18 infant, 18-29 young, 29 - 50 middle aged, 50 - 69 old, 69 - and older really old. Report the number of people in each age group. (use some random data for test). B). They need some statistics regarding the distribution of ages. Write a program to...

  • Write the program in C The following statistics for cities of the Vege country are stored...

    Write the program in C The following statistics for cities of the Vege country are stored in a file: Name: a string of characters less than 15 characters long. Population: an integer value. Area: square miles of type double Write a program that: asks and gets the name of the input file from the user. Read the contents of the file into an array length 10 of structures -ask the user for the name of a city (less than 15...

  • Write a program that calculates the average number of days a company's employees are absent during the year and outputs a report on a file named "employeeAbsences.txt".

    Project DescriptionWrite a program that calculates the average number of days a company's employees are absent during the year and outputs a report on a file named "employeeAbsences.txt".Project SpecificationsInput for this project:the user must enter the number of employees in the company.the user must enter as integers for each employee:the employee number (ID)the number of days that employee missed during the past year.Input Validation:Do not accept a number less than 1 for the number of employees.Do not accept a negative...

  • In C++, Please help me compute the following flowchart exactly like this requirement: Use while loops...

    In C++, Please help me compute the following flowchart exactly like this requirement: Use while loops for the input validations required: number of employees(cannot be less than 1) and number of days any employee missed(cannot be a negative number, 0 is valid.) Each function needs a separate flowchart. The function charts are not connected to main with flowlines. main will have the usual start and end symbols. The other three functions should indicate the parameters, if any, in start; and...

  • This application is for you, the shopper in mind. Putting together an itemized shopping list that...

    This application is for you, the shopper in mind. Putting together an itemized shopping list that contains the items you need, the items you want, and the anticipated cost, this program will generate a total price. This way you can decide if your shopping budget fits the bill. Example list: Price List Binder paper: 2.29 Mop: 7.50 Scouring pads: 5 Your application program will create and write a new list to an output file in which the need and wish...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT