Вы находитесь на странице: 1из 7

COP 3223 Introduction to C Fall 2015 Section 5

Assignment 9
Assigned November 13th and Due Friday 20th November 2015 at 11:30 pm.
This assignment is worth a maximum of 100 points
Objectives:
.
The purpose of this assignment, is for students to demonstrate the ability to use

C syntax for 2D array declaration


C syntax and semantics for processing 2D arrays
C syntax and semantics to create user defined functions
syntax for C file input
C syntax to format output data
C syntax and semantics to create a program that compiles and runs correctly
Comments to annotate code

Problem
You have been hired to develop software to maintain the performance statistics for the tennis
pro Marisol Bohen. Your software should track her performance for the 12 months of the year. Each
month there are 8 tennis tournaments. She may or may not participate in every tournament. When she
does not participate, this is indicated this with a score of 0.
Your software should read Marisols score data from an input file- scores.txt, and store the values in a
2D array. It should also facilitate queries on Marisols performance to obtain the following:
1. Her score for any given tournament in a given month
2. Her average and maximum score for the year
3. Her average and maximum score for a given month

You will provide the features above by writing functions to compute or retrieve the required
information.
When your program is run, it should display a menu of the available features as shown in the sample
run. A User will be able to select an option from the menu. This will evoke the appropriate function call.
The menu displayed should be as shown in the sample output with options 0-7.

Page 1 of 7

Your solution to this problem should include the following 10 functions:


1.

makeArray: This function takes a file pointer and a 2D array of scores as its parameters and
updates the array to reflect the score values read from the input file.

2. getScore: This function takes the array of scores, a month and tournament number (both given
as integers), and returns Marisols score for that particular game. The months are numbered 112.*
3. getMonthMax: This function takes the array of scores, a month (given as an integer *) and
returns Marisols maximum score for that month.
4. getYearMax: This function takes the array of scores and returns the maximum score made for
the whole year.
5. getMonthAvg: This function takes the array of scores, a month (given as an integer *) and
returns Marisols average score for that month.
6. getYearAvg: This function takes the array of scores and returns the average score made for the
whole year.
7. toursMissed: This function takes the array of scores and returns the number of tournaments
that Marisol did not participate in for year.
8. displayMenu: This function prints out the set of options available to the users. The display
format is as shown in the sample output.
9. processRequest: This function takes the array of scores and an integer representing the option
selected by the user. During its execution it also obtains any additional information required to
process the user request. It calls the appropriate function and then displays the appropriate
result.
10.

printArray: This function takes the array of scores and prints out all of the scores stored for the
year. The scores should be printed out in the format shown in the sample output.
Submission of Assignment

Your assignment should be submitted via Webcourses by the deadline. No assignments will be accepted
via email. Your submission should be a single .c file called tennis.c . Note that you do not have to submit
the input file. Your program will be graded using DevC++, so be sure that your submitted code runs
correctly in this IDE. If you do not have DevC++ on your personal machine, you may use a computer in
any lab to test your code. Remember that any program submitted which does not compile, can only
receive a maximum of 30% of the total grade. Depending on the quality of code submitted, the actual
grade may be less than the maximum.

Page 2 of 7

Restrictions:

Your program should be written to read an input file named scores.txt and write output to the
screen
The scores file will contain 96 integers each separated by at least 1 space character (it may be
more than 1). The data will be terminated by the number 999.
You may assume that all of the numbers in the file are legitimate integer scores.
Remember that the sample input file and screen output, are just samples of possible data that
can be used to test your program. The actual input file used to run your code, will always match
the format described in this section, but may be different in content from the sample input file.
For example:
o There may be more or less spaces between the scores
o The distribution of scores obtained will most likely be different

Sample input/output
Your program should run on any input file that matches the format of the sample scores.txt below
26

35

25

92

47

68

26

72

67

33

84

28

22

36

53

66

23

86

36 75

14

62

43

11

42

14

58

23

30

87

80 81

13

35

94

45

53

14

55

46

19

13

25 28

66

86

69

81

15

55

60

26

70

22

36

15 67

62

16

71

29

92

84

37

30

4 50

67

53

69

87

23

74

58

86

78 88

85

12

52

Page 3 of 7

999

Sample screen output

Page 4 of 7

Page 5 of 7

Page 6 of 7

Page 7 of 7

Вам также может понравиться