关于java:介绍CSE-1223

36次阅读

共计 7799 个字符,预计需要花费 20 分钟才能阅读完成。

CSE 1223: Introduction to Computer Programming in Java
Students:
This content is controlled by your instructor, and is not zyBooks content. Direct questions or concerns
about this content to your instructor. If you have any technical issues with the zyLab submission
system, use the Trouble with lab button at the bottom of the lab.
11.39 Data Analysis
For this project you will be analyzing some population data that comes from the US Census
Bureau. In the US the ocial
Census is taken every 10 years, but in the years in between the
US Census Bureau creates population estimates based on data they collect. This data is
publicly available at the US Census Bureau’s website.
In this project we will be looking at les
that have population estimates by county for various
states . Your job is to write a program that will load this data and prepare a report
summarizing some statistics about population in a given state.
The le
format is the same as in the lab from this week – here is an excerpt of the rst
10
lines:
The rst
line is a header which indicates what is in each column. The remaining lines in the
le
have a line of data each showing a comma-separated list of population values with the
county name in the rst
position and the population estimates for each year from 2010
through 2019 afterwards.
Your job is to use this datale
format to produce a formatted output le
generating the
statistics listed below. Your program should prompt the user for a datale
to read
information from and then a number of counties listed in the data le.
YOU MUST DESIGN AT
County,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019
Adams,28537,28459,28293,28089,28066,27926,27807,27753,27694,27698
Allen,106358,105988,105244,105055,104848,104095,103613,103093,10272
Ashland,53321,53252,53239,53153,53161,53310,53520,53662,53706,53484
Ashtabula,101403,101085,100252,99746,99027,98404,98171,97748,97587,
Athens,65173,65079,64610,64594,64783,65886,66352,66503,65519,65327
Auglaize,45898,45741,45770,45801,45737,45734,45766,45753,45736,4565
Belmont,70333,70122,69709,69563,69367,68973,68606,68002,67533,67006
Brown,44863,44629,44281,44111,43933,43697,43638,43523,43570,43432
Butler,369102,370123,370550,371395,373750,375998,378354,380607,3820
2021/4/6 Section 11.39 – CSE 1223: Introduction to Computer Programming in Java
https://learn.zybooks.com/zyb… 2/6
LEAST 3 METHODS FOR THIS PROGRAM!! If you write this program in a single main method
you WILL lose points even if you pass all of the test cases.
Read the necessary elements from the le
into a set of parallel arrays (as described in the
previous lab) and then compute the statistics listed below:
Enter a data file to read: OhioPopulationData.csv
Enter the number of counties: 88
County Pop 2010 Pop 2019 Growth Pct Grow


Adams 28537 27698 -839 -2.94%
Allen 106358 102351 -4007 -3.77%
Ashland 53321 53484 163 0.31%
Ashtabula 101403 97241 -4162 -4.10%
Athens 65173 65327 154 0.24%
Auglaize 45898 45656 -242 -0.53%
Belmont 70333 67006 -3327 -4.73%
Brown 44863 43432 -1431 -3.19%
Butler 369102 383134 14032 3.80%
Carroll 28846 26914 -1932 -6.70%
Champaign 40078 38885 -1193 -2.98%
Clark 138274 134083 -4191 -3.03%
Clermont 197604 206428 8824 4.47%
Clinton 41922 41968 46 0.11%
Columbiana 107890 101883 -6007 -5.57%
Coshocton 36938 36600 -338 -0.92%
Crawford 43754 41494 -2260 -5.17%
Cuyahoga 1278088 1235072 -43016 -3.37%
Darke 52963 51113 -1850 -3.49%
Defiance 39082 38087 -995 -2.55%
Delaware 175099 209177 34078 19.46%
Erie 76978 74266 -2712 -3.52%
Fairfield 146417 157574 11157 7.62%
Fayette 29014 28525 -489 -1.69%
Franklin 1166202 1316756 150554 12.91%
Fulton 42629 42126 -503 -1.18%
Gallia 31072 29898 -1174 -3.78%
Geauga 93389 93649 260 0.28%
Greene 161588 168937 7349 4.55%
Guernsey 40155 38875 -1280 -3.19%
Hamilton 802278 817473 15195 1.89%
Hancock 74689 75783 1094 1.46%
Hardin 32127 31365 -762 -2.37%
Harrison 15825 15040 -785 -4.96%
Henry 28171 27006 -1165 -4.14%
Highland 43621 43161 -460 -1.05%
Hocking 29478 28264 -1214 -4.12%
Holmes 42473 43960 1487 3.50%
2021/4/6 Section 11.39 – CSE 1223: Introduction to Computer Programming in Java
https://learn.zybooks.com/zyb… 3/6
Huron 59560 58266 -1294 -2.17%
Jackson 33248 32413 -835 -2.51%
Jefferson 69670 65325 -4345 -6.24%
Knox 61090 62322 1232 2.02%
Lake 230014 230149 135 0.06%
Lawrence 62424 59463 -2961 -4.74%
Licking 166705 176862 10157 6.09%
Logan 45743 45672 -71 -0.16%
Lorain 301478 309833 8355 2.77%
Lucas 441434 428348 -13086 -2.96%
Madison 43434 44731 1297 2.99%
Mahoning 238381 228683 -9698 -4.07%
Marion 66458 65093 -1365 -2.05%
Medina 172509 179746 7237 4.20%
Meigs 23731 22907 -824 -3.47%
Mercer 40788 41172 384 0.94%
Miami 102487 106987 4500 4.39%
Monroe 14609 13654 -955 -6.54%
Montgomery 535597 531687 -3910 -0.73%
Morgan 15034 14508 -526 -3.50%
Morrow 34790 35328 538 1.55%
Muskingum 86214 86215 1 0.00%
Noble 14660 14424 -236 -1.61%
Ottawa 41359 40525 -834 -2.02%
Paulding 19557 18672 -885 -4.53%
Perry 36037 36134 97 0.27%
Pickaway 55740 58457 2717 4.87%
Pike 28612 27772 -840 -2.94%
Portage 161386 162466 1080 0.67%
Preble 42170 40882 -1288 -3.05%
Putnam 34476 33861 -615 -1.78%
Richland 124162 121154 -3008 -2.42%
Ross 78098 76666 -1432 -1.83%
Sandusky 60885 58518 -2367 -3.89%
Scioto 79664 75314 -4350 -5.46%
Seneca 56618 55178 -1440 -2.54%
Shelby 49349 48590 -759 -1.54%
Stark 375372 370606 -4766 -1.27%
Summit 541645 541013 -632 -0.12%
Trumbull 209840 197974 -11866 -5.65%
Tuscarawas 92543 91987 -556 -0.60%
Union 52464 58988 6524 12.44%
Van Wert 28678 28275 -403 -1.41%
Vinton 13405 13085 -320 -2.39%
Warren 213429 234602 21173 9.92%
Washington 61713 59911 -1802 -2.92%
Wayne 114394 115710 1316 1.15%
2021/4/6 Section 11.39 – CSE 1223: Introduction to Computer Programming in Java
https://learn.zybooks.com/zyb… 4/6
Williams 37512 36692 -820 -2.19%
Wood 125950 130817 4867 3.86%

Wyandot 22588 21772 -816 -3.61%

Total 11539336 11689100 149764 1.30%
Most growth: Franklin (150554)
Biggest loss: Cuyahoga (-43016)
Largest Pct growth: Delaware (19.46%)
Largest Pct loss: Carroll (-6.70%)
Average 2019 Population per County: 132830
Num. Counties with 2019 Pop. Larger Than Average: 21
The Growth column shows how much the population has increased since 2010. The Pct
Growth shows how much the population has changed as a percentage of its 2010 value.
Your report should print out which county has the largest absolute growth (raw population
increase), the largest loss (raw population decrease), the largest percentage of population
growth (growth as a percentage of its 2010 population value) and the largest percentage of
population loss (decrease as a percentage of its 2010 population value).
The above transcript shows the OhioPopulationData.csv le
outputs. There are three
other similar les
here to look through for Indiana, California and Wyoming that use the same
naming convention (IndianaPopulationData.csv,
CaliforniaPopulationData.csv, and WyomingPopulationData.csv). See which of
these states has the largest growth, which has the smallest growth, and which has the
largest and smallest percentage growth relative to their 2010 baseline.
The number of counties in each state are:
California: 58
Indiana: 92
Ohio: 88
Wyoming: 23
NOTE: Remember that you can use the System.out.format() method to get nicely
formatted output (as we used in the Trajectory Modelling assignment). If you want to include
a percentage sign in a format String use %% to indicate that a percent symbol should be
printed.
NOTE 2: The String type has a method named split() that takes a String you want to
split on and returns an array of String values based around that split. For example, if you
have the following segment of code it will split the String named line into the String
array vals as shown below:
String line =
“Adams,28537,28459,28293,28089,28066,27926,27807,27753,27694,27698”
String[] vals = line.split(“,”);
2021/4/6 Section 11.39 – CSE 1223: Introduction to Computer Programming in Java
https://learn.zybooks.com/zyb… 5/6
NOTE 3: Remember that you can use Integer.parseInt() to convert a String value to an
integer value.
285300.1745892.qx3zqy7
// vals =
[“Adams”,”28537″,”28459″,”28293″,”28089″,”28066″,27926″,”27807″,”27
LAB
ACTIVITY
11.39.1: Data Analysis 0 / 4
Downloadable les
DataAnalysis.java , OhioPopulationData.csv ,
IndianaPopulationData.csv ,
WyomingPopulationData.csv , and
CaliforniaPopulationData.csv
Run your program as often as you’d like, before
submitting for grading. Below, type any needed
input values in the rst
box, then click Run
program and observe the program’s output in the
second box.
Predene
program input (optional)
If you’d like to predene
your inputs, provide them here.
Download
DataAnalysis.java Load default template…
Develop mode Submit mode
Run my program Stop Clear terminal
import java.util.Scanner;
public class DataAnalysis {
public static void main(String[] args) {
/ Type your code here. /

}
}
2021/4/6 Section 11.39 – CSE 1223: Introduction to Computer Programming in Java
https://learn.zybooks.com/zyb… 6/6
Signature of your work
History of your effort will appear here once you begin
working on this zyLab.

What is this?
Trouble with lab?

正文完
 0