assignment 9.pdf

7
7/23/2019 Assignment 9.pdf http://slidepdf.com/reader/full/assignment-9pdf 1/7 Page 1 of 7 COP 3223 Introduction to C Fall 2015 Section 5 Assignment 9 Assigned November 13 th and Due Friday 20 th 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 Marisol’s score data from an input file - scores.txt, and store the values in a 2D array. It should also facilitate queries on Marisol’s 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.

Upload: vinny-tran

Post on 18-Feb-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Assignment 9.pdf

7/23/2019 Assignment 9.pdf

http://slidepdf.com/reader/full/assignment-9pdf 1/7

Page 1 of 7

COP 3223 Introduction to C Fall 2015 Section 5

Assignment 9

Assigned November 13 th and Due Friday 20 th 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 tennispro Marisol Bohen. Your software should track her performance for the 12 months of the year. Eachmonth there are 8 tennis tournaments. She may or may not participate in every tournament. When shedoes not participate, this is indicated this with a score of 0.

Your software should read Marisol’s score data from an input file - scores.txt, and store the values in a

2D array. It should also facilitate queries on Marisol’s 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 requiredinformation.

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 2: Assignment 9.pdf

7/23/2019 Assignment 9.pdf

http://slidepdf.com/reader/full/assignment-9pdf 2/7

Page 2 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 andupdates 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 givenas integers), an d returns Marisol’s score for that particular game. The months are numbered 1-12. *

3. getMonthMax: This function takes the array of scores, a month (given as an integer *) andreturns Marisol’s maximum score for that month.

4. getYearMax : This function takes the array of scores and returns the maximum score made forthe whole year.

5. getMonthAvg : This function takes the array of scores, a month (given as an integer *) and

returns Marisol’s average score for that month.

6. getYearAvg : This function takes the array of scores and returns the average score made for thewhole year.

7. toursMissed : This function takes the array of scores and returns the number of tournamentsthat Marisol did not participate in for year.

8. displayMenu: This function prints out the set of options available to the users. The displayformat is as shown in the sample output.

9. processRequest : This function takes the array of scores and an integer representing the optionselected by the user. During its execution it also obtains any additional information required toprocess the user request. It calls the appropriate function and then displays the appropriateresult.

10. printArray : This function takes the array of scores and prints out all of the scores stored for theyear. 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 acceptedvia email. Your submission should be a single .c file called tennis.c . Note that you do not have to submitthe input file. Your program will be graded using DevC++, so be sure that your submitted code runscorrectly in this IDE. If you do not have DevC++ on your personal machine, you may use a computer inany lab to test your code. Remember that any program submitted which does not compile, can onlyreceive a maximum of 30% of the total grade. Depending on the quality of code submitted, the actualgrade may be less than the maximum.

Page 3: Assignment 9.pdf

7/23/2019 Assignment 9.pdf

http://slidepdf.com/reader/full/assignment-9pdf 3/7

Page 3 of 7

Restrictions:

Your program should be written to read an input file named scores.txt and write output to thescreen

The scores file will contain 96 integers each separated by at least 1 space character (it may bemore 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 matchthe 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 scoreso 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 0 6 47 68 26 72 67 33 84 28

22 36 53 66 23 86 36 75 14 62 43 11 42 5

14 58 0 23 30 87 80 81 13 35 94 45 1 53

14 55 46 19 13 0 25 28 66 86 69 0 81 15

55 60 26 70 22 36 15 67 62 16 71 7 29 92

84 37 2 30 7 5 4 50 0 67 2 53 69 87

8 23 74 58 86 0 78 88 85 12 1 52 999

Page 4: Assignment 9.pdf

7/23/2019 Assignment 9.pdf

http://slidepdf.com/reader/full/assignment-9pdf 4/7

Page 4 of 7

Sample screen output

Page 5: Assignment 9.pdf

7/23/2019 Assignment 9.pdf

http://slidepdf.com/reader/full/assignment-9pdf 5/7

Page 5 of 7

Page 6: Assignment 9.pdf

7/23/2019 Assignment 9.pdf

http://slidepdf.com/reader/full/assignment-9pdf 6/7

Page 6 of 7

Page 7: Assignment 9.pdf

7/23/2019 Assignment 9.pdf

http://slidepdf.com/reader/full/assignment-9pdf 7/7

Page 7 of 7