In: Computer Science
C Programming
Game Scores Assignment
Outcome:
Student will demonstrate the ability to design a menu driven program.
Student will demonstrate the ability to create and use a 2D array on
the stack.
Student will demonstrate the use of functions.
Student will demonstrate good programming style.
Program Specifications:
***********************************************
** MAIN MENU **
***********************************************
A) Enter game results
B) Current Record (# of wins and # of losses and # of ties)
C) Display ALL results from all games WON
D) Display ALL results ordered by opponent score from low to high.
E) Quit
Your program will have a menu similar to the example above. The game
results will simply be the score by your team and the score by your
opponent. The user will enter a single game result at a time. This
assignment requires the use of a 2D array. You will not need the date of
the game or the names of the teams. All cases will be written within user
defined function. Functions should be used as much as possible.
Submission Requirements:
Requirements will be same as the first assignment which will be the same
for all future assignments.
YOU CANNOT
Use global variables, in this or any program ever.
Use goto statement(s), in this or any program ever.
Note for the tutor : Please create a design tools after you done with the work
Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
#include <stdio.h>
#include <stdlib.h>
int main(){
int n;
int A[100];
int B[100];
int games = 0;
while (1){
printf("%s
","***********************************************");
printf("%s ","** MAIN MENU **");
printf("%s
","***********************************************");
printf("%s ","A) Enter game results");
printf("%s ","B) Current Record (# of wins and # of
losses)");
printf("%s ","C) Display ALL results from all games WON");
printf("%s ","D) Display ALL results");
printf("%s ","E) Quit");
printf("ENter Your Choice (1-5) : ");
scanf("%d",&n);
if (n == 1){
while (1){
printf("%s","Enter Your Score (-1 to Quit) ");
int input;
scanf("%d",&input);
if (input == -1)
break;
A[games] = input;
printf("%s","Enter Your Opponent Score (-1 to Quit) ");
scanf("%d",&input);
B[games] = input;
games += 1;
}
}
else if (n == 2){
int i = 0;
int wins = 0;
int loss = 0;
while (i < games){
if (A[i] > B[i])
wins += 1;
else
loss += 1;
i += 1;
}
printf("Wins : %d ",wins);
printf("Loss : %d ",loss);
}
else if (n == 3){
int i = 0;
while (i < games){
if (A[i] > B[i])
printf("game: %d Status: Win ",(i+1));
i += 1;
}
}
else if (n == 4){
int i = 0;
while (i < games){
if (A[i] > B[i])
printf("game: %d Status: Win ",(i+1));
else
printf("game: %d Status: Loss ",(i+1));
i += 1;
}
}
else
break;
}
}
Kindly revert for any queries
Thanks.