You will be using a data file called “christmas.dat”. To copy the data file to your directory, do
cp /export/home/public/may/christmas.dat christmas.dat
There will be one line for each elf. That line will contain the name of the elf and the number of
toys the elf made.
You need to declare three arrays to store names, numbers, and ratings for the elves. Make sizes
of the arrays 50.
Read from the file the name of each elf and number of toys made by the elf into your arrays.
You do not know how many elves there are, you only know there are less than 50, so you must
read until the end of file and count.
Determine the rating for each elf based on the number made.
Toys Made Rating
500 or more *****
between 300 and 499 ***
between 200 and 299 *
under 200 -
The program should then print out
the three arrays side by side in neat, labeled columns.
the total number of toys made by the elves
the number of elves who made more than 500 toy
the name of the elf who made the most toys
the name of the elf who made the least toys
Requirements for using functions
Each calculation should have a function of its own. NO output should be done in functions that
do calculations. Remember to always pass the number of elements in the array with the array to
functions. You should have at least the following four functions (you may choose different
function names):
o getTotalNumber
o getNumberOver500
o getNameMost
o getNameLeast
Sample:
>./a.out
Elf Report:
=========================================
Name Toys Made Rating
-----------------------------------------
Smiley 662 *****
Curley 88 -
Clementine 335 ***
Jasper 105 -
Lucinda 775 *****
Brunhilda 103 -
Florence 441 ***
Oskar 820 *****
Snowflake 990 *****
Bernard 690 *****
Punch 298 *
Chuckie 10 -
Frosty 102 -
Snowman 311 ***
April 830 *****
Merry 299 *
Sunshine 331 ***
Buddy 1234 *****
Carol 271 *
Misty 111 -
Harold 52 -
Henry 292 *
Twinkle 308 ***
Starlight 703 *****
Burr 112 -
Angelica 444 ***
Bluenose 689 *****
Harry 254 *
Twinkle 259 *
Stardust 121 -
Greensleeves 453 ***
Noel 312 ***
Happy 209 *
Yukon 534 *****
Snowcap 190 -
Northpole 598 *****
Total toys made: 14336
There are 11 elves who made more than 500 toys.
Buddy made the most toys.
Chuckie made the least toys.