BEST代写-最专业、靠谱的代写

Best代写-最专业、靠谱的代写IT&CS | 留学生作业 |编程代写 | Java | Python | C/C++ | PHP | Matlab | Assignment Project Homework代写

C++代写 | DataStructure Pointer File IO Github | OSU‑CS162‑W19

C++代写 | DataStructure Pointer File IO Github | OSU‑CS162‑W19

OSUu2011CS162u2011W19u7684Assignmentu20111uff0cu672cu6b21u4ee3u5199u4e3aC++u57fau7840u4f5cu4e1auff0cu8bbeu8ba1C++u6570u636eu7ed3u6784u3001u6307u9488u3001u6587u4ef6u6d41u3001u6587u4ef6u8bfbu53d6u7b49uff0cu96beu5ea6u4e2du4e0bu3002

The goals of this assignment are to brush off your C++ skills by working with struct s and pointers and to start practicing
some of the new things we’re learning in this class, like file I/O. Follow the directions below, and make sure your source code
files (no executable files, .o files, or other crufty stuff) are committed and pushed back into your repository on GitHub
to earn credit for the assignment.

1. Sign up for Piazza
Use this link to sign up for CS 162 on Piazza
We’ll be using Piazza in this course for Q&A because it’s geared towards students helping other students with the class.
Anyone can post or answer a question on Piazza, even anonymously, and the instructor and TAs can revise and endorse
student answers, which means you can be confident in the quality of the response.
You are strongly encouraged to post any classu2011related questions to Piazza first instead of emailing the instructor or TAs.
You should also get in the habit of checking in to Piazza to answer other students’ questions. This will not only enable
everyone to get help quickly, but it will also help you improve your understanding of the material, since teaching someone
else is the best way to learn something.
As an incentive to use Piazza, extra credit will be awarded to the most active Piazza participants at the end of the class.

2. Write a program to explore state/county economic data
Write a program to explore a small set of state and county economic data. Specifically, your program should take a single
command line argument which contains the path to a file containing state and county economic data. For example, if your
executable program is called explore_econdata , you should be able to run it like this:
./explore_econdata test_data.txt
Your program must read all of the data from the file that is specified and then allow the user to interactively explore that
data.
Data file format and storage
The file will contain the following data for some number of states:
Statewide 2007 unemployment rate
Statewide 2015 unemployment rate
Statewide median household income

For some number of counties in the state:
County 2007 unemployment rate
County 2015 unemployment rate
County median household income
It will have the following format:
n_states
state_name state_07_unemployed state_15_unemployed state_med_income n_counties
county_1_name county_1_07_unemployed county_1_15_unemployed county_1_med_income

county_n_name county_n_07_unemployed county_n_15_unemployed county_n_med_income
state_name state_07_unemployed state_15_unemployed state_med_income n_counties

For example, here’s what a very small data file might look like:
2
Oregon 5.2 5.7 51088 3
Benton 4.1 4.3 54089
Linn 6.3 6.9 44358
Multnomah 4.9 5.0 53519
California 5.4 6.2 61927 2
Alameda 4.7 4.7 76996
San_Francisco 4.2 3.6 83788
A more extensive set of data is provided for you in test_data.txt . You can use this file to test your program.
To hold this data, your program should use these two structures:
struct county {
std::string name;
float unemployed_2007;
float unemployed_2015;
int med_income;
};
structstate {
std::string name;
float unemployed_2007;
float unemployed_2015;
int med_income;
struct county* counties;
int n_counties;
};
Your program should use the first value in the file ( n_states ) to allocate a dynamic array of type struct state big
enough to hold data about all of the states. Then, it should read the info about the first state and dynamically allocate the
state’s array of counties based on its value of n_counties . After the county array is allocated, you can read the county data
for the state and store if in the county array. Repeat this process for each of the states.
Program features
After your program reads and stores the state and county data from the specified file, it should allow the user to
interactively explore the data. Specifically, you should allow the user to do these things:
Print the state with the highest median household income.
Print the state with the lowest median household income.
Print the state with the highest unemployment in 2015.
Print the state with the lowest unemployment in 2015.

Program design
It is up to you how to design an interface to allow the user to perform the tasks above. A system of menus where the user
can enter values (e.g. integer values) to select operations from those menus is one option.
Your program should contain at least the following functions (keeping these prototypes):
struct state* allocate_states(int) u2011 Allocates an array of a specified number of states.
void read_state_data(struct state*, int, std::ifstream&) u2011 Reads data for a specified number of states from an
input file stream into a given (preu2011allocated) array.
struct county* allocate_counties(int) u2011 Allocates an array of a specified number of counties.
void read_county_data(struct county*, int, std::ifstream&) u2011 Reads data for a specified number of counties
from an input file stream into a given (preu2011allocated) array.
void free_state_data(struct state*, int) u2011 Releases all data (including county data) allocated to given array. You
must make sure to call this function when needed to make sure any allocated data is freed before it is lost or before the
program exits.
In addition, you should write any other functions needed to implement the features described above. Your program should
be well modularized. That is, your program should be factored into reasonablyu2011sized (preferably small) functions that each
perform some specific logical task.
You should separate your source code into interface

bestdaixie

评论已关闭。