Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA PROBLEM: The President of the United States is elected by winning the most electoral votes. Each state is allocated a certain number of electoral

JAVA PROBLEM:

The President of the United States is elected by winning the most electoral votes. Each state is allocated a certain number of electoral votes. The candidate with the most votes in a states wins all the electoral votes for that state.

Write a program that uses the file ElectoralVotes.csv and the varous Election Data files to calculate the number of electoral votes earned by each candidate in each election

Your program should build a lookup table with the state names, another table with the associated electoral votes for that state.

The output for each election should show two numbers the total electoral votes earned by each candidate. Optionally, you could print each states name , the winner, and number of electoral votes won.

ElectoralVotes.csv
State
Idaho
Maryland
Kentucky
Arizona
Arkansas
California
Colorado
Alaska
Delaware
D. C.
Illinois
Georgia
Hawaii
Connecticut
Minnesota
Indiana
Iowa
Kansas
Alabama
Maine
Florida
Massachusetts
Michigan
Louisiana
Mississippi
Missouri
Montana
Nebraska
Nevada
New Hampshire
New Jersey
New Mexico
New York
North Carolina
North Dakota
Ohio
Oklahoma
Oregon
Pennsylvania
Rhode Island
South Carolina
South Dakota
Tennessee
Texas
Utah
Vermont
Virginia
Washington
West Virginia
Wisconsin
Wyoming
Electoral Votes
4
10
8
8
6
54
8
3
3
2
22
13
4
8
10
12
7
6
9
4
25
12
18
9
7
11
3
5
4
4
15
5
33
14
3
21
8
7
23
4
8
3
11
32
5
3
13
11
5
11
3
ElectionData 2004
State
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
D. C.
Florida
Georgia
Hawaii
Idaho
Illinois
Indiana
Iowa
Kansas
Kentucky
Louisiana
Maine
Maryland
Massachusetts
Michigan
Minnesota
Mississippi
Missouri
Montana
Nebraska
Nevada
New Hampshire
New Jersey
New Mexico
New York
North Carolina
North Dakota
Ohio
Oklahoma
Oregon
Pennsylvania
Rhode Island
South Carolina
South Dakota
Tennessee
Texas
Utah
Vermont
Virginia
Washington
West Virginia
Wisconsin
Wyoming
BUSH
190889
1104294
572898
5509826
1101256
693826
171660
21256
3964522
1914254
194191
409235
2345946
1479438
751957
736456
1069439
1102169
330201
1024703
1071109
2313746
1346695
684981
1455713
266063
512814
418690
331237
1670003
376930
2962567
1961166
196651
2859768
959792
866831
2793847
169046
937974
232584
1383336
4526917
663742
121180
1716959
1304894
423778
1478120
167629
KERRY
111025
893524
469953
6745485
1001725
857488
200152
202970
3583544
1366149
231708
181098
2891550
969011
741898
434993
712733
820299
396842
1334493
1803800
2479183
1445014
458094
1259171
173710
254328
397190
340511
1911430
370942
4314280
1525849
111052
2741167
503966
943163
2938095
259760
661699
149244
1035160
2832704
241199
184067
1454742
1510201
326541
1489504
70776
ElectionData 2008
State
Alabama
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
D. C.
Florida
Georgia
Hawaii
Idaho
Illinois
Indiana
Iowa
Kansas
Kentucky
Louisiana
Maine
Maryland
Massachusetts
Michigan
Minnesota
Mississippi
Missouri
Montana
Nebraska
Nevada
New Hampshire
New Jersey
New Mexico
New York
North Carolina
North Dakota
Ohio
Oklahoma
Oregon
Pennsylvania
Rhode Island
South Carolina
South Dakota
Tennessee
Texas
Utah
Vermont
Virginia
Washington
West Virginia
Wisconsin
Wyoming
Obama
813479
123594
1034707
422310
8274473
1288633
997773
255459
245800
4282367
1844123
325871
236440
3419348
1374039
828940
514765
751985
782989
421923
1629467
1904098
2872579
1573354
554662
1441911
232159
333319
533736
384826
2215422
472422
4804945
2142651
141403
2940044
502496
1037291
3276363
296571
862449
170924
1087437
3528633
327670
219262
1959532
1750848
303857
1677211
82868
McCain
1266546
193841
1230111
638017
5011781
1073629
629428
152374
17367
4046219
2048759
120566
403012
2031179
1345648
682379
699655
1048462
1148275
295273
959862
1108854
2048639
1275409
724597
1445814
243882
452979
412827
316534
1613207
346832
2752771
2128474
168887
2677820
960165
738475
2655885
165391
1034896
203054
1479178
4479328
596030
98974
1725005
1229216
397466
1262393
164958
ElectionData 2012
State
California
Maryland
Alaska
Arizona
Arkansas
Kansas
Colorado
North Carolina
Iowa
D. C.
Florida
Georgia
Hawaii
Idaho
Illinois
Indiana
Alabama
Delaware
Kentucky
Louisiana
Maine
Nevada
Massachusetts
Michigan
Minnesota
Mississippi
Missouri
Montana
Nebraska
Connecticut
New Hampshire
New Jersey
New Mexico
New York
North Dakota
Ohio
Oklahoma
Oregon
Pennsylvania
Rhode Island
South Carolina
South Dakota
Tennessee
Texas
Utah
Vermont
Virginia
Washington
West Virginia
Wisconsin
Wyoming
OBAMA
7854285
1677844
122640
1025232
394409
439908
1323102
2178391
822544
267070
4237756
1773827
306658
212787
3019512
1154275
795696
242584
679370
809141
401306
531373
1921761
2564569
1546167
562949
1223796
201839
302081
905109
369561
2126610
415335
4485877
124827
2827709
443547
970488
2990274
279677
865941
145039
960709
3308124
251813
199239
1971820
1755396
238269
1620985
69286
ROMNEY
4839958
971869
164676
1233654
647744
689809
1185243
2270395
730617
21381
4163447
2078688
121015
420911
2135216
1422872
1255925
165484
1087190
1152262
292276
463567
1188460
2115256
1320225
710746
1482440
267928
475064
634899
329918
1478749
335788
2490496
188163
2661437
891325
754175
2680434
157204
1071645
210610
1462330
4569843
740600
92698
1822522
1290670
417655
1407966
170962

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_2

Step: 3

blur-text-image_3

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

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

How is the concept of matching usually applied to period costs?

Answered: 1 week ago

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago