modernkilla82

Untitled

Apr 14th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. //*********************************************
  2. //** Written by..: Jason Bonomo
  3. //** Date Written: April 14, 2019
  4. //** Assignment.....: Eaxm Four: The Election
  5. //*********************************************
  6. #define _CRT_SECURE_NO_WARNINGS
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #define PAUSE system("pause")
  10. #define CLS system("cls")
  11. #define FLUSH myFlush();
  12. //Array Size
  13. #define SIZE 49
  14. //Flush
  15. void myFlush() {
  16. while (getchar() != '\n');
  17. }
  18.  
  19. void displayMenu(){
  20. CLS;
  21. printf(" The Election \n", 'N');
  22. printf("[I]vanka Trump>Enter Votes \n");
  23. printf("[M]ichele Obama>Enter Votes \n");
  24. printf("[D]isplay Total Votes for each candidate \n");
  25. printf("[A]ll votes in order \n");
  26. printf("[Q]uit\n\n");
  27. printf("Make a selection: ");
  28. }
  29.  
  30. char getChoice(){
  31. char result;
  32. displayMenu();
  33. scanf("%c", &result);
  34. return toupper(result);
  35. }
  36.  
  37. void displayMessage(char string[], char);
  38. void displayMenu();
  39. char getChoice();
  40. void myFlush();
  41.  
  42. main() {
  43. int VoteIvanka;
  44. int VoteMichele;
  45.  
  46. int StatesArray[SIZE];
  47.  
  48. char userChoice = ' ';
  49. do{
  50. userChoice = getChoice();
  51. switch(userChoice){
  52. //Enter Votes for Ivanka Trump
  53. case 'I':
  54. printf("Enter Votes for Ivanka Trump: \n"); FLUSH;
  55. scanf("%i", &VoteIvanka);
  56. break;
  57. //Enter Votes for Michele Obama
  58. case 'M':
  59. printf("Enter Votes for Michele Obama: \n"); FLUSH;
  60. scanf("%i", &VoteMichele);
  61. //Total Votes for Each Candidate
  62. case 'D':
  63. printf("%d \n", &VoteIvanka);
  64. printf("%d \n", &VoteMichele);
  65. break;
  66. //All Votes for Each Candidate in order
  67. case 'A':
  68. printf("PLACE HOLDER \n"); FLUSH;
  69. break;
  70. //Display Quit Option
  71. case 'Q':
  72. printf("You have Quit the program! :( \n"); FLUSH;
  73. break;
  74. default:
  75. printf("You must pick a choice from the menu!");
  76. break;
  77. }
  78. }while(userChoice != 'Q');
  79.  
  80.  
  81. PAUSE;
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment