Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

5.2. Write a function vote to cast a vote. The function does not have any inputs

ID: 3842543 • Letter: 5

Question

5.2. Write a function vote to cast a vote. The function does not have any inputs. It will return a struct Ballot. It will displaya title for proposition 75 (you can make up this proposition and give it a title), prompt the user to vote on prop 75, display the possible candidates, and prompt the user to vote for a candidate. When voting for a candidate it should provide the candidate with the various options and assign the appropriate enum value to the candidate field of the struct. It should also assign a unique ballot ID using the ballotCount global variable and increment the ballotCount global variable afterwards. Note, the global variable ballotCount is initialized to 0 (to keep an accurate count) but the ballot ID's assigned should start at 1. Initially set mark the ballot as valid (the valid field of the ballot should be set to true). If the user enters an invalid response to any of the prompts, mark the ballot invalid (change the valid field to false). Don't forget that you will need to remove the newline character from the input buffer after a value is scanned in from the user. You can use the following line after a scanf s: while (getchar0 An); //to keep it simple we are ignoring EOF in this case Write a main function to call the function vote multiple times in order to fully test the vote function. Verify the votes are correct by printing them in the main function. Use the printBallot function provided below. Also print the value of the global variable ballotCount to verify that it has incremented properly.

Explanation / Answer

#include #include void main() { int age ; clrscr() ; printf("Enter the age : ") ; scanf("%d", &age) ; if(age >= 18) printf(" The person is eligible to vote.") ; else printf(" The person is not eligible to vote.") ; getch() ; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote