Advertisement
jackiebinya

menudrivenGame.c

May 25th, 2018
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.80 KB | None | 0 0
  1. int main()
  2. {
  3. printf("Welcome to MathoMania\n");
  4. printf("\n*********************************************************\n");
  5.  
  6. //user prompts to enter values
  7. int num1, num2;
  8. printf("Enter any two random numbers:\n");
  9. scanf("%d%d", &num1, &num2);
  10.  
  11. printf("\n****************************MENU****************************\n");
  12.  
  13. printf("1. Perform a Modulus Division on two numbers.\n");
  14. printf("2. Perform Multiplication on two numbers.\n");
  15. printf("3. Perform Subtraction of two numbers.\n");
  16. printf("4. Exit\n");
  17.  
  18. int option;
  19. printf("\nPlease enter the number that coincides with your option.\n");
  20. scanf("%d", &option);
  21.  
  22. int answer1, answer2, answer3;
  23. answer1 = num1 % num2;
  24. answer2 = num1 * num2;
  25. answer3 = num1 - num2;
  26.  
  27. int answerFromUser1, answerFromUser2, answerFromUser3;
  28.  
  29. int newAnswer1, newAnswer2, newAnswer3;
  30.  
  31. switch (option)
  32. {
  33. case 1:
  34. printf("\nEnter the result:\n") ;
  35. scanf("%d", &answerFromUser1);
  36.  
  37. if ( answerFromUser1 == answer1)
  38. printf("Congratulations your answer is correct!!!\n");
  39. else if ( answerFromUser1 != answer1)
  40. {
  41. printf("\nYour answer is incorrect.\n");
  42. printf("Please try again enter new answer:\n");
  43. scanf("%d", &newAnswer1);
  44. if ( newAnswer1 == answer1)
  45. printf("Congratulations your answer is correct!!!\n");
  46. else if ( newAnswer1 != answer1)
  47. {
  48. printf("Your answer is incorrect you have exhausted all your chances.\n");
  49. printf("The correct answer is %d.\n", answer1);
  50.  
  51. }
  52. }
  53. break;
  54. case 2:
  55. printf("\nEnter the result:\n") ;
  56. scanf("%d", &answerFromUser2);
  57.  
  58. if ( answerFromUser2 == answer2)
  59. printf("Congratulations your answer is correct!!!\n");
  60. else if ( answerFromUser2 != answer2)
  61. {
  62. printf("\nYour answer is incorrect.\n");
  63. printf("Please try again enter new answer:\n");
  64. scanf("%d", &newAnswer2);
  65. if ( newAnswer2 == answer2)
  66. printf("Congratulations your answer is correct!!!\n");
  67. else if ( newAnswer2 != answer2)
  68. {
  69. printf("Your answer is incorrect you have exhausted all your chances.\n");
  70. printf("The correct answer is %d.\n", answer2);
  71.  
  72. }
  73. }
  74. break;
  75.  
  76. case 3:
  77. printf("\nEnter the result:\n") ;
  78. scanf("%d", &answerFromUser3);
  79.  
  80. if ( answerFromUser3 == answer3)
  81. printf("Congratulations your answer is correct!!!\n");
  82. else if ( answerFromUser3 != answer3)
  83. {
  84. printf("\nYour answer is incorrect.\n");
  85. printf("Please try again enter new answer:\n");
  86. scanf("%d", &newAnswer3);
  87. if ( newAnswer3 == answer3)
  88. printf("Congratulations your answer is correct!!!\n");
  89. else if ( newAnswer3 != answer3)
  90. {
  91. printf("Your answer is incorrect you have exhausted all your chances.\n");
  92. printf("The correct answer is %d.\n", answer3);
  93.  
  94. }
  95. }
  96. break;
  97.  
  98. case 4:
  99. break;
  100.  
  101. }
  102.  
  103. printf("\n*****************************************************************\n");
  104. printf("\nTHANKS FOR PLAYING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
  105.  
  106.  
  107. return 0;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement