CSCI 111

Program #5

Due November 3, 2016

In this program, we will use an array of structuresto store and manipulate our data.

CMU Distributing is a small distributing company in Grand Junction and would like a program to do the following tasks.Declare constants maxsales = 15, and maxm = 6. Declare a structure type named Salestype which will have the following fields: id (integer), first and last (strings), hired (integer), and an array of sales for the first half year- an array of up to maxm doubles, as well as Q1, Q2 and Total as doubles. In main, declare an array of such structures called Sales, declared with maxsales. Write a program to do the following:

A)Call a function to initialize the array using a constantinitrec (as shown in class) for all fields. Be sure to use zeros for all values which could be totaled up.

B)Call a function to read the id, first name, last name, year the salesman was hired, and the sales for the six months. Note: you MUST use a loop to read in the monthly sales. Calculate numsales, the number of salesmen read in.

C)Call a function to determine Q1, Q2, and total for each salesman and store them in the appropriate field.

D)Sort the data by the ID field, then print the arrays in tabular form. You should also output the column totals under the appropriate columns.

E)Code a function SalesStars to find the salesman with the highest first quarter sales, the highest second quarter sales, and the salesman who sold the most over the six months. Print each with appropriate messages.

F)Write a linear search function, so that if sent an ID number, the name and total sales of that salesmen will be printed to the output file with an appropriate message. Test this by searching for 6072, David Tang.

G) Write a search function which search by last name (sent to the function). Since last name is not a unique identifier, print all those salesmen who have the last name (print id and their complete name) with an appropriate message. Test the function using “Hudson”.

Here’s the input data:

Sales (In Thousands)
ID / First / Last / Hired / Jan / Feb / Mar / Apr / May / June
1113 / Lori / Payne / 1986 / 150 / 208 / 203 / 85 / 190 / 195
3057 / Henry / Hudson / 2001 / 98 / 200 / 211 / 155 / 185 / 195
7051 / George / Jetson / 1995 / 177 / 210 / 220 / 100 / 205 / 210
5018 / Jack / Benson / 2015 / 125 / 138 / 150 / 75 / 115 / 95
8156 / George / Lucero / 2013 / 203 / 200 / 205 / 100 / 108 / 104
6072 / David / Tang / 2011 / 165 / 168 / 169 / 130 / 155 / 159
2133 / Ona / Bhutto / 2000 / 83 / 105 / 120 / 135 / 140 / 148
3268 / George / Williams / 2016 / 79 / 120 / 90 / 111 / 133 / 125
8909 / Jane / Hudson / 1990 / 100 / 100 / 100 / 100 / 100 / 100
9375 / Andrea / Young / 2010 / 121 / 159 / 165 / 173 / 184 / 199
1999 / Mandy / Proctor / 2016 / 108 / 122 / 200 / 155 / 166 / 110
7272 / Jack / White / 2014 / 175 / 110 / 215 / 218 / 220 / 200