Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I Was posted 4 Questions and all of them answered incorrect please don't copy and i need the correct code will be run well Question

I Was posted 4 Questions and all of them answered incorrect please don't copy and i need the correct code will be run well

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Question 2: (80 marks) *Unlike many elections for public office where a person is elected strictly based on the results of a popular vote (.e., the candidate who earns the most votes in the election wins), in the United States, the election for President of the United States is determined by a process called the Electoral College. According to the National Archives, the process was established in the United States Constitution as a compromise between election of the President by a vote in Congress and election of the President by a popular vote of qualified citizens." (https://tasks.illustrativemathematics.org/content- standards/tasks/1199 accessed November 22, 2020). Each state receives an allocation of electoral votes in the process, and this allocation is determined by the number of members in the state's delegation to the US Congress. This number is the sum of the number of US Senators that represent the state (always 2, per the Constitution) and the number of Representatives that represent the state in the US House of Representatives (a number that is directly related to the state's population of qualified citizens as determined by the US Census). Therefore the larger a state's population of qualified citizens, the more electoral votes it has. Note: the District of Columbia (which is not a state) is granted 3 electoral votes in the process through the 23rd Amendment to the Constitution. The following table shows the allocation of electoral votes for each state and the District of Columbia for the 2012, 2016, and 2020 presidential elections. (http://www.archives.gov/federal- register/electoral-college/allocation.html accessed November 22, 2020). Total Electoral Votes: 538; Majority Needed to Elect: 270 State State State Electoral votes 9 Electoral votes 8 Electoral vates 3 18 7 7 20 11 55 9 Alabama Alaska Arizona Arkansas California Colorado Connecticut Delaware District of Columbia Florida Georgia Hawaii Idaho Illinois Indiana lowa Kansas 9 4 10 11 16 10 6 10 Kentucky Louisiana Maine Maryland Massachusetts Michigan Mini Mississippi Missouri Montana Nebraska Nevada New Hampshire New Jersey New Mexico New York North Carolina 3 29 16 North Dakota Ohio Oklahoma Oregon Pennsylvania Rhode Island Carolin South Dakota Tennessee Texas Utah Vermont Virginia Washington West Virginia Wisconsin Wyoming 3 11 20 11 5 6 4 14 5 29 15 13 12 5 10 3 6 M251-M257/ THE-Final 3 of 6 2020-2021/Fall The Constitution does not specify how individual states must allocate their electoral votes. There are different methodologies. In US election 2020, all states, except Maine and Nebraska (in red), have a winner-take-all (WTA) method where the state looks only at the overall winner of the state-wide popular vote. The WTA awards all electoral votes to the popular vote winner of the state. Maine and Nebraska both use an alternative method of distributing their electoral votes, called the Congressional District Popular method (CDP). Maine has two congressional districts while Nebraska has three congressional districts due to its population. The winner of each congressional district (CD) is awarded one electoral vote, and the winner of the state-wide vote is then awarded the state's remaining two electoral votes. In US election 2020, a vote for the Presidential candidate is for either Trump or Biden. a) Design and implement Java classes to represent the following 1. Candidate: each object of which represents one candidate, consisting of a name, and the number of electoral and popular votes received by that candidate so far. (7 marks) 2. Using Java Comparator interface, implement necessary classes in order to compare candidate objects on the basis of the data members, the number popular votes or the electoral votes. This would help you to find Collections.maxl) either based on popular votes or electoral votes. (6 marks: 3 marks for each comparison class) 3. State: each object of which represents one state, consisting of the number of electoral votes allocated for that state, list of candidates and the state certified winner. (10 marks) 4. WTA State: each object of which represents one state type that implements WTA method and it consists of an ArrayList of votes. Each vote consist of a name of the presidential candidate for US. (In 2020 presidential election, votes are for either "Trump" or "Biden"). (3 marks) 5. CDP State: each object of which represents one state type that implements CDP method and it consists of an ArrayList of votes for each CD. (3 marks) Note: In each class, implement constructors and appropriate accessor and mutator methods. b) In each state type, define necessary methods compute the number of popular votes and the number of electoral votes received by each presidential candidate in one state based on its implemented methodology. Use Collections.frequencyl) and Collections.maxl) to count votes and assign the winner respectively. (8 marks for computing votes in WTA state + 15 marks for computing votes in CDP state) c) Redefine the method toString() in the following classes: 1. Candidate class to concatenate the state name and the number of popular and electoral votes received by a candidate object. (1 mark) 2. State class to concatenate the state name and the number of popular and electoral votes received by each candidate. In addition to the state certified winner details. (4 marks) d) Design and implement a test class. This should contain a main method to do the following (23 marks): 1. Write a method that randomly generates an odd number of votes in the range 1-10.(3 marks) 2. Write a recursive method that fills and returns a list of random votes for either Trump or Biden of length n where n is an odd number. (Call your method in d(1) to get an odd number to be sent as parameter to the recursive fill method). (6 marks) 3. Create a list of candidates that consists of the two candidates; Trump and Biden for 2020 US presidential election. (2.5 marks) 4. Create a list of US states. Fill in the list of states with hard-coded test data (no user input) from the table above. The states list should hold at least five state objects of any type (WTA and CDP states) where at least one of states is a CDP state. Call your method in d(2) to get a randomly generated votes list for each state or CD. (5 marks) 5. For each state, display the candidate list and the state certified winner. At end, announce the overall US Presidential Election Results 2020 for each candidate and the certified winner. (6.5 marks) Sample run which takes from table 1, the first four states in addition to Nebraska. The state's output was generated from randomly generated vates list: Alabama Candidate Trump: Candidate Biden Winner: Candidate Trump: Popular votes 4 Popular votes 3 Electoral votes 9 Electoral votes 0 Popular votes 4 Electoral votes 9 Alaska Candidate Trump Candidate Biden Popular votes 1 Popular votes 4 Electoral votes 0 Electoral votes 3 Winner: Candidate Biden Popular votes 4 Electoral votes 3 Arizona Candidate Trump: Candidate Biden Winner Popular votes 2 Popular votes 3 Electoral votes 0 Electoral votes 11 Candidate Biden Popular votes Electoral votes 3 11 Popular votes Electoral votes Arkansas Candidate Trump Candidate Biden: Winner: Candidate Trump: Popular votes Electoral votes 3 0 Popular votes Electoral votes 6 Nebraska Candidate Trump: Candidata Biden Winner: Candidate Biden Popular votes Electoral votes 10 1 Popular votes Electoral votes 15 4 Popular votes Electoral votes 15 23 US Presidential Election Results 2020: Candidate Popular votes Electoral votes Trump 16 Candidate Popular votes Electoral votes Biden 18 Winner Candidate Popular votes Electoral votes Biden 28 18 Question 2: (80 marks) *Unlike many elections for public office where a person is elected strictly based on the results of a popular vote (.e., the candidate who earns the most votes in the election wins), in the United States, the election for President of the United States is determined by a process called the Electoral College. According to the National Archives, the process was established in the United States Constitution as a compromise between election of the President by a vote in Congress and election of the President by a popular vote of qualified citizens." (https://tasks.illustrativemathematics.org/content- standards/tasks/1199 accessed November 22, 2020). Each state receives an allocation of electoral votes in the process, and this allocation is determined by the number of members in the state's delegation to the US Congress. This number is the sum of the number of US Senators that represent the state (always 2, per the Constitution) and the number of Representatives that represent the state in the US House of Representatives (a number that is directly related to the state's population of qualified citizens as determined by the US Census). Therefore the larger a state's population of qualified citizens, the more electoral votes it has. Note: the District of Columbia (which is not a state) is granted 3 electoral votes in the process through the 23rd Amendment to the Constitution. The following table shows the allocation of electoral votes for each state and the District of Columbia for the 2012, 2016, and 2020 presidential elections. (http://www.archives.gov/federal- register/electoral-college/allocation.html accessed November 22, 2020). Total Electoral Votes: 538; Majority Needed to Elect: 270 State State State Electoral votes 9 Electoral votes 8 Electoral vates 3 18 7 7 20 11 55 9 Alabama Alaska Arizona Arkansas California Colorado Connecticut Delaware District of Columbia Florida Georgia Hawaii Idaho Illinois Indiana lowa Kansas 9 4 10 11 16 10 6 10 Kentucky Louisiana Maine Maryland Massachusetts Michigan Mini Mississippi Missouri Montana Nebraska Nevada New Hampshire New Jersey New Mexico New York North Carolina 3 29 16 North Dakota Ohio Oklahoma Oregon Pennsylvania Rhode Island Carolin South Dakota Tennessee Texas Utah Vermont Virginia Washington West Virginia Wisconsin Wyoming 3 11 20 11 5 6 4 14 5 29 15 13 12 5 10 3 6 M251-M257/ THE-Final 3 of 6 2020-2021/Fall The Constitution does not specify how individual states must allocate their electoral votes. There are different methodologies. In US election 2020, all states, except Maine and Nebraska (in red), have a winner-take-all (WTA) method where the state looks only at the overall winner of the state-wide popular vote. The WTA awards all electoral votes to the popular vote winner of the state. Maine and Nebraska both use an alternative method of distributing their electoral votes, called the Congressional District Popular method (CDP). Maine has two congressional districts while Nebraska has three congressional districts due to its population. The winner of each congressional district (CD) is awarded one electoral vote, and the winner of the state-wide vote is then awarded the state's remaining two electoral votes. In US election 2020, a vote for the Presidential candidate is for either Trump or Biden. a) Design and implement Java classes to represent the following 1. Candidate: each object of which represents one candidate, consisting of a name, and the number of electoral and popular votes received by that candidate so far. (7 marks) 2. Using Java Comparator interface, implement necessary classes in order to compare candidate objects on the basis of the data members, the number popular votes or the electoral votes. This would help you to find Collections.maxl) either based on popular votes or electoral votes. (6 marks: 3 marks for each comparison class) 3. State: each object of which represents one state, consisting of the number of electoral votes allocated for that state, list of candidates and the state certified winner. (10 marks) 4. WTA State: each object of which represents one state type that implements WTA method and it consists of an ArrayList of votes. Each vote consist of a name of the presidential candidate for US. (In 2020 presidential election, votes are for either "Trump" or "Biden"). (3 marks) 5. CDP State: each object of which represents one state type that implements CDP method and it consists of an ArrayList of votes for each CD. (3 marks) Note: In each class, implement constructors and appropriate accessor and mutator methods. b) In each state type, define necessary methods compute the number of popular votes and the number of electoral votes received by each presidential candidate in one state based on its implemented methodology. Use Collections.frequencyl) and Collections.maxl) to count votes and assign the winner respectively. (8 marks for computing votes in WTA state + 15 marks for computing votes in CDP state) c) Redefine the method toString() in the following classes: 1. Candidate class to concatenate the state name and the number of popular and electoral votes received by a candidate object. (1 mark) 2. State class to concatenate the state name and the number of popular and electoral votes received by each candidate. In addition to the state certified winner details. (4 marks) d) Design and implement a test class. This should contain a main method to do the following (23 marks): 1. Write a method that randomly generates an odd number of votes in the range 1-10.(3 marks) 2. Write a recursive method that fills and returns a list of random votes for either Trump or Biden of length n where n is an odd number. (Call your method in d(1) to get an odd number to be sent as parameter to the recursive fill method). (6 marks) 3. Create a list of candidates that consists of the two candidates; Trump and Biden for 2020 US presidential election. (2.5 marks) 4. Create a list of US states. Fill in the list of states with hard-coded test data (no user input) from the table above. The states list should hold at least five state objects of any type (WTA and CDP states) where at least one of states is a CDP state. Call your method in d(2) to get a randomly generated votes list for each state or CD. (5 marks) 5. For each state, display the candidate list and the state certified winner. At end, announce the overall US Presidential Election Results 2020 for each candidate and the certified winner. (6.5 marks) Sample run which takes from table 1, the first four states in addition to Nebraska. The state's output was generated from randomly generated vates list: Alabama Candidate Trump: Candidate Biden Winner: Candidate Trump: Popular votes 4 Popular votes 3 Electoral votes 9 Electoral votes 0 Popular votes 4 Electoral votes 9 Alaska Candidate Trump Candidate Biden Popular votes 1 Popular votes 4 Electoral votes 0 Electoral votes 3 Winner: Candidate Biden Popular votes 4 Electoral votes 3 Arizona Candidate Trump: Candidate Biden Winner Popular votes 2 Popular votes 3 Electoral votes 0 Electoral votes 11 Candidate Biden Popular votes Electoral votes 3 11 Popular votes Electoral votes Arkansas Candidate Trump Candidate Biden: Winner: Candidate Trump: Popular votes Electoral votes 3 0 Popular votes Electoral votes 6 Nebraska Candidate Trump: Candidata Biden Winner: Candidate Biden Popular votes Electoral votes 10 1 Popular votes Electoral votes 15 4 Popular votes Electoral votes 15 23 US Presidential Election Results 2020: Candidate Popular votes Electoral votes Trump 16 Candidate Popular votes Electoral votes Biden 18 Winner Candidate Popular votes Electoral votes Biden 28 18

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

' How much control do you have over achieving your objectives?

Answered: 1 week ago

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago