Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //*********************************************
- //** Written by..: Jason Bonomo
- //** Date Written: April 14, 2019
- //** Assignment.....: Eaxm Four: The Election
- //*********************************************
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <stdlib.h>
- #define PAUSE system("pause")
- #define CLS system("cls")
- #define FLUSH myFlush();
- //Array Size
- #define SIZE 49
- //Flush
- void myFlush() {
- while (getchar() != '\n');
- }
- void displayMenu(){
- CLS;
- printf(" The Election \n", 'N');
- printf("[I]vanka Trump>Enter Votes \n");
- printf("[M]ichele Obama>Enter Votes \n");
- printf("[D]isplay Total Votes for each candidate \n");
- printf("[A]ll votes in order \n");
- printf("[Q]uit\n\n");
- printf("Make a selection: ");
- }
- char getChoice(){
- char result;
- displayMenu();
- scanf("%c", &result);
- return toupper(result);
- }
- void displayMessage(char string[], char);
- void displayMenu();
- char getChoice();
- void myFlush();
- main() {
- int VoteIvanka;
- int VoteMichele;
- int StatesArray[SIZE];
- char userChoice = ' ';
- do{
- userChoice = getChoice();
- switch(userChoice){
- //Enter Votes for Ivanka Trump
- case 'I':
- printf("Enter Votes for Ivanka Trump: \n"); FLUSH;
- scanf("%i", &VoteIvanka);
- break;
- //Enter Votes for Michele Obama
- case 'M':
- printf("Enter Votes for Michele Obama: \n"); FLUSH;
- scanf("%i", &VoteMichele);
- //Total Votes for Each Candidate
- case 'D':
- printf("%d \n", &VoteIvanka);
- printf("%d \n", &VoteMichele);
- break;
- //All Votes for Each Candidate in order
- case 'A':
- printf("PLACE HOLDER \n"); FLUSH;
- break;
- //Display Quit Option
- case 'Q':
- printf("You have Quit the program! :( \n"); FLUSH;
- break;
- default:
- printf("You must pick a choice from the menu!");
- break;
- }
- }while(userChoice != 'Q');
- PAUSE;
- }
Advertisement
Add Comment
Please, Sign In to add comment