Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. /* Program to determine seed score */
  2.  
  3. #include <stdio.h>
  4. #include <stdbool.h>
  5.  
  6. int main (void) {
  7. int PlayerOneScore, PlayerTwoScore, RoundsPlayed, PlayerOneWins, PlayerTwoWins, MaxWins;
  8. bool Proceed;
  9.  
  10. PlayerOneScore = PlayerTwoScore = 128;
  11.  
  12. for (Proceed = false; Proceed == false;) {
  13. printf("Enter the number of rounds played: ");
  14. scanf("%i", &RoundsPlayed);
  15. if (RoundsPlayed < 3)
  16. printf("Rounds played must be three or more.\n\n");
  17. else if (RoundsPlayed % 2 == 0)
  18. printf("Rounds played cannot be even.\n\n");
  19. else
  20. Proceed = true;
  21. }
  22.  
  23. if (RoundsPlayed == 3)
  24. MaxWins = 2;
  25. else
  26. MaxWins = 2 + (RoundsPlayed / 3);
  27.  
  28. printf("Player 1's score is %i\n", PlayerOneScore);
  29. printf("Player 2's score is %i\n", PlayerTwoScore);
  30.  
  31. for (Proceed = false; Proceed == false;) {
  32. printf("Best of %i rounds.\n", RoundsPlayed);
  33. printf ("Max wins = %i.\n", MaxWins);
  34. printf("Enter how many wins Player 1 has: ");
  35. scanf("%i", &PlayerOneWins);
  36. getchar();
  37. printf("Enter how many wins Player 2 has: ");
  38. scanf("%i", &PlayerTwoWins);
  39. getchar();
  40. if (PlayerOneWins < 0 || PlayerTwoWins < 0) {
  41. printf("Neither score can be less than zero. Please re-enter the score.\n\n");
  42. }
  43. else if ((PlayerOneWins + PlayerTwoWins) > RoundsPlayed) {
  44. printf("The sum of both scores is greater than the number of rounds played. Please re-enter the score.\n\n");
  45. }
  46. else if (PlayerOneWins > MaxWins || PlayerTwoWins > MaxWins) {
  47. printf("Neither score are greater than the maximum wins allowed in the match. Please re-enter the score.\n\n");
  48. }
  49. else if (PlayerOneWins == 0) {
  50. PlayerOneScore -= PlayerTwoWins;
  51. PlayerTwoScore += PlayerTwoWins;
  52. Proceed = true;
  53. }
  54. else if (PlayerTwoWins == 0) {
  55. PlayerOneScore += PlayerOneWins;
  56. PlayerTwoScore -= PlayerOneWins;
  57. Proceed = true;
  58. }
  59. else if (PlayerOneWins > PlayerTwoWins) {
  60. PlayerOneScore += (PlayerOneWins - PlayerTwoWins);
  61. PlayerTwoScore -= (PlayerOneWins - PlayerTwoWins);
  62. Proceed = true;
  63. }
  64. else {
  65. PlayerOneScore -= (PlayerTwoWins - PlayerOneWins);
  66. PlayerTwoScore += (PlayerTwoWins - PlayerOneWins);
  67. Proceed = true;
  68. }
  69. }
  70.  
  71. printf("Player 1's score is %i\n", PlayerOneScore);
  72. printf("Player 2's score is %i\n", PlayerTwoScore);
  73.  
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement