Project #6
(Charity Survey)
(Due 28 April 2008)
Last fall, a group of charities got together to conduct a survey of Christmas shoppers. Someone had the bright idea to give out short survey cards to people standing in line waiting to purchase their Christmas gifts. So, an army of volunteers spread out across the country and stationed themselves in several prominent department stores (with the store's permission). The surveys were handed out to the shoppers and collected at the cash registers. Now the companies want the collected survey data analyzed and you are to write a program to help do that.
The survey asked the following questions. The shopper's responses were stored in one line of a file with one space separating answers to the individual questions.
What is your age? - answered
with an integer
What is your sex? - answered with
F or M
How many people do you buy gifts for?
- answered with an integer
How much money do you expect to spend
today? - answered with an integer
How do you usually pay for gifts? - answered
with $ for cash, C for credit card, or K for check
Do you plan or have you already given
to charity as part of Christmas giving? - answered with Y or N
If answered Y, how
many charities? - answered with an integer
If answered N, have
you given to charity earlier this year? - answered with Y or N
What is the approximate amount of your
charitable giving this year? - answered with an integer
Here are the first few lines from the minisurvey.txt file:
47 F 4 200 C N N 0
36 M 16 50 $ Y 2 40
70 F 4 280 C N Y 1200
The first person is a 47 year-old woman who is shopping for 4 gifts, has spent $200 today, pays by credit card, has not given to charity as part of Christmas giving and also did not give earlier in the year. The second is a 36 year-old man who is shopping for 16 gifts, has spent $50 today, pays in cash, has given to 2 charities as part of Christmas giving and has given $40 for the year. The underlined entries in the displays (cross tabulations) show where these three people were counted.
Your program is required to read the survey file and produce several report displays. Two of these displays are cross tabulations (2-dimensional displays showing the number of people in each of several categories). The first display shows the age of the person versus the amount of total giving for the year. People are to be grouped by age as 12-21, 22-34, 35-44, 45-59, 60 or more. People are to be grouped by the amount given as 0, 1-50, 51-100. 101-500, 501-1000, 1001 or more. For the minisurvey.txt file, the first display should look like this:
Giving by Age
Dollars Given to Charity
Ages
None 1-50 51-100
101-500 501-1000 >1000
12-21
2 1
0 0
0 0
22-34
1 2
0 0
0 4
35-44
0 1
1 1
0 1
45-59
1 6
2 1
0 0
>=60
1 2
1 1
0 1
The second display shows the number of gifts to buy versus the total giving for the year. The number of gifts to buy are grouped as 1, 2-3, 4-6, 7-10, 10-15, 16 or more. For the minisurvey.txt file, the display should look like this.
Giving by No. of Gifts to Buy
Dollars Given to Charity
# Gifts
None 1-50 51-100
101-500 501-1000 >1000
1
0 0
0 0
0 0
2-3
1 2
0 0
0 2
4-6
1 3
1 0
0 1
7-10
1 2
1 2
0 1
10-15
2 2
2 1
0 2
>15
0 3
0 0
0 0
In addition to the cross tabulations, your program should produce two displays showing the percentages of people based on one question. The percentages should be rounded to the nearest whole percent. The first of these displays should show the percentages of people in each category associated with the amount of spent on that day. The categories for spending are 1-50, 51-100, 101-200, and 201 or more. For the minisurvey.txt file, this display should look like this:
Amount Spent That Day
1-50
21%
51-100
21%
100-200
44%
>200
17%
The second display should show the percentage of people who are given to each number of charities as part of Christmas giving. The number of charities is not categorized, each is counted separately. For the minisurvey.txt file, this display should look like this:
Number of Charities Given Year-End Gifts
1
27%
2
7%
3
11%
8
4%
12
11%
Notice that only numbers that have some percentage are listed. Also, notice that because not everyone gives a year-end gift, the percentages do not add up to anything close to 100%. For the other first percentage display, the percentages should add to near 100%.
Finally, the program should display the total number of people surveyed.
Two files are provided to you. The first is minisurvey.txt - it contains a small sample of the kind of data from the survey. You should practice on this file; all answers for this file will be provided on WebCT. The second file is the actual survey data; its name is collection.txt - it contains thousands of survey responses. Both files can be found on the I:\ drive at I:\jlwolfe\110
Hand in a well-documented printout of your program and a printout of the captured output showing the results of analyzing the collection.txt file. Also, copy the program's .cpp file to the handin folder on the P: drive for COSC 110, your section. Be sure to name the .cpp file after yourself so that it can be distinguished from other student file names. For example, I would name my file wolfep6.cpp
Extra Credit Opportunities:
Make a third cross tabulation display showing the payment method versus the total giving for the year. The payment methods are cash, credit card, and check.
Make a fourth cross tabulation displaying the amount spent on that day versus the total giving for the year. The categories for spending are 1-50, 51-100, 101-200, and 201 or more.
Make a third percentage display showing the percentage of people based on their method of payment (cash, credit card, or check).