Chat with us, powered by LiveChat I Have Managed To Get Through Creating The Menu And Outputting Options 1,2 And 3 , As Well As Ending The Program, | Writedemy

I Have Managed To Get Through Creating The Menu And Outputting Options 1,2 And 3 , As Well As Ending The Program,

I Have Managed To Get Through Creating The Menu And Outputting Options 1,2 And 3 , As Well As Ending The Program,

I have managed to get through creating the menu and outputting options 1,2 and 3 , as well as ending the program, However, I have not been able to figure out how to code the remaining options. My code is posted below the dotted line at the bottom of instructions. This is done in C Programming Language. Thank you in advance!

Program Specifications:

Let’s pretend that we are tracking votes for the next presidential election. There will be two candidates: Ivanka Trump and Michele Obama.

You can assume that there are fifty states casting votes. You will do not need to deal with the names of the states, you can assume that state 0 = the first state and state 49 = the last state.

This program will have menu system. The menu will at least have the following options:

                                    ***********************************************************

                                    **                   CNN VOTER COLLECTION PROGRAM MAIN MENU            **

                                    ***********************************************************

  1. Enter Votes from a state for Ivanka Trump
  2. Enter Votes from a state for Michele Obama
  3. Display total votes for each candidate
  4. Display the all votes for a selected candidate in order
  5. List the state number(s) where Trump and Obama received the exact same number of votes
  6. For each candidate display the highest number of votes from any state, the lowest number of votes from any state, the average number of votes from all states.
  7. Election is over, Exit Program

Comments:

When the user presses (1) or (2) from above, the program will ask the user to enter a value for the NEXT state. You can assume that the first time they press (1) from the main menu they were entering votes for state ZERO. The second time for the FIRST state. The user will only be typing a single number (the number of votes for that state). The control of the program will bounce back to the main menu.

Note: The votes are not from a single voter, but from ALL votes cast for that candidate from that state.

When the user selects (3) you will simply show the votes by state for each candidate.

State           Trump         Obama

0                87876           78877

1                98776           576788

When the user presses (4) sort the votes from low to high and display them.

When the user presses (5) the program will create a statement or statements such as:

Obama and Trump each got 2345 votes from state 8.

When the user presses (6) the program will display by state the lowest number of votes for a candidate from any one state, the average votes by a candidate from any one state.

When the user presses (7)…you figure it out.

Submission Requirements:

Your source code must have a comment header and comments within the code.Y ou must provide a well written design tool that matches the code and was generated by a computer application. You must do error checking in at least 2 places within the code. You must have a bubble sort and some type of search function. Everything must be written in functions. Main can only have variables, a loop and a switch.

—————————————————————————————————————-

void printHeader()
{
printf(“***********************************************************\n”);
printf(“**     CNN VOTER COLLECTION PROGRAM MAIN MENU            **\n”);
printf(“***********************************************************\n”);
}

// Since we are using arrays, we will use init to clear them ahead of time.
void init(int trump[], int obama[],int n)
{
int i;
for(i=0; i<n; i++)
{
trump[i]=0;
obama[i]=0;
}
}

// Setting up the displays before the main function clear clutter from int main.
void displayVotes(int trump[], int obama[],int n)
{
int i;
printf(“State\tTrump\tObama\n”);
for(i=0; i<n; i++)
{
printf(“%d\t%d\t%d\n”,i,trump[i],obama[i]);
}
}

// Start of main Function
int main()
{
//Declare Variables here
int numberOfStates=49;
int votesTrump[numberOfStates];
int votesObama[numberOfStates];
init(votesTrump,votesObama,numberOfStates);
printHeader();
int choice, stateT=0,stateO=0, votesT, votesO;

//The while loop below keeps the menu up while the user uses the menu, until option seven is selected
//which means there will be 7 possible switch cases, denominating each possible option in the menu.
while(1)
{
printf(“1.Enter Votes from a state for Ivanka Trump \n”);
printf(“2.Enter Votes from a state for Michelle Obama\n”);
printf(“3.Display total votes for each candidate\n”);
printf(“4.Display the all votes for a selected candidate in order\n”);
printf(“5.List the state number(s) where Trump and Obama \n received the exact same number of votes \n”);
printf(“6.For each candidate display the highest number of \n votes from any state, the lowest number of \n votes from any state, the average number of votes from all states. \n”);
printf(“7.Election is over, Exit Program \n\n”);
printf(“Enter your choice : “);
scanf(“%d”,&choice);
//The switch statement below denotes the options given and the calculations to provide the results.
switch(choice)
{
case 1:
printf(“Enter number of votes:\n”);
scanf(“%d”,&votesT);
votesTrump[stateT%numberOfStates]= votesTrump[stateT%numberOfStates] + votesT;
stateT++;
break;

case 2:
printf(“Enter number of votes:\n”);
scanf(“%d”,&votesO);
votesObama[stateO%numberOfStates]= votesObama[stateO%numberOfStates] + votesO;
stateO++;
break;

case 3:
displayVotes(votesTrump,votesObama,numberOfStates);
break;

case 4:
break;

case 5:
break;

case 6:
break;
case 7:
//Last option in the menu terminates the program.
printf(“Thank you, the program will now terminate. \n”);
exit(0);
}

}
//End of Main Function

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Writedemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order