Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Intro: We will also be using GitHub to complete this project. GitHub is a repository hosing service that allows you to collaborate and work on

Intro:
We will also be using GitHub to complete this project. GitHub is a repository hosing service that allows you to collaborate and work on projects from anywhere. GitHub provides guides that help you understand GitHub better.
Setup:
Setup a GitHub account (if you do not already have one) and install GitHub Desktop. Instructions are here Download here.
To create the GitHub repository with the files I have already created for you to complete the project, do the following:
Click on this linkLinks to an external site. and accept the assignment.
You can then get to the GitHub repository by using the link provided after you accept the assignment.
Follow these instructions on how to pull the files from the repo down to your computer and then push the files back to the repo once you have modified them.
Once you have cloned the repo to your computer you will open the project folder in Netbeans and begin coding in the file with the main method already provided for you.
The Problem:
A city needs your help accumulating candidate election votes from local three precincts. The two candidates running for election are Mr. Smith and Carter Pewterschmidt.
You are to write a program that will assist them in tabulating the votes on Election Day. You will use two int arrays to store the election results, one array for each candidate. The array elements will store the election results for each precinct.
Follow the guidelines listed below exactly.
The overall goal of this project is to allow your client
Enter number of votes for a particular candidate at three different precincts.
Calculate the total votes for that candidate.
Determine the candidate with the highest votes.
There are two candidates.
The project must allow your client to input the number of votes for each candidate from the three precincts and store them in an array. This task must be accomplished using a for
Write a static value returning method that will be used to calculate the total votes for each candidate from the precincts and store them in an appropriate variable.
Allow the client to change the number of votes for a particular candidate from a particular precinct and update the total votes of that candidate. This loop must be accomplished using a while loop.
Write a static void method to determine and display the winner
The project will contain two methods, findTotalVotes() and displayWinner()
findTotalVotes() will contain one formal parameter (an array) and return an int value. Its method heading is shown below.
public static int findTotalVotes(int[] votes)
displayWinner() will contain two formal parameters and will not return a value. Its method heading is shown below.
public static void displayWinner(int firstCandidate, int secondCandidate)
Be sure to use descriptive variable names, proper indentation, appropriate white space, and appropriate document to explain your code.
Sample Run
A sample run of the project is shown below. (User input is shown in bold.)
Enter your votes for each candidate by precinct
Precinct 1 votes:
Mr. Smith votes: 100
Carter Pewterschmidt votes: 100
Precinct 2 votes:
Mr. Smith votes: 200
Carter Pewterschmidt votes: 200
Precinct 3 votes:
Mr. Smith votes: 300
Carter Pewterschmidt votes: 300
The votes for each candidate are:
Mr Smith: 600
Carter Pewterschmidt: 600
It is a tie!
Do you have any recounts? 1 for Yes, 2 for No: 1
Select the appropriate candidate number below.
1. Mr. Smith
2. Carter Pewterschmidt
Candidate number: 2
Please select a precinct to change
1. Precinct 1
2. Precinct 2
3. Precinct 3
Precinct number: 1
Please enter the number of votes: 1000
Do you have any recounts? 1 for Yes, 2 for No: 2
The votes for each candidate are:
Mr. Smith: 600
Carter Pewterschmidt: 1500
Carter Pewterschmidt with 1500 votes is the winner
Additional Information:
Your program should work whether the user input is in upper or lower case
All output needs to be formatted specifically as shown within the files and console window
Must include the header as outlined in the Programming Style Guidelines
Include appropriate comments to document your program.
Programming Suggestions:
When writing your program, write a small set of Java statements at a time, and then compile your Java program. This way you will be able to identify your errors as you develop your program.
Do not add any features to the program that you turn in. Do not include Java statements that we have not studied at this point in the course.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions