IUP Computer Science
COSC 110
 
 

Exercise #5

A survey was taken of customers at Walmart and Boscov's.  Each person was asked for his/her name (first name only) and to state how much cash s/he had in his/her pocket or purse.  The information was collected into a file named  survey.txt  The people surveyed at Walmart are first in the file, one person per line; then, there is a line that looks like this
       FAKE   -1.0    This is then followed by the information about the people surveyed at Boscov's, one person per line.  Here are a few lines from the file.

Amy        34.38
Tom        83.25
Maria      39.15
.
.
FAKE       -1.0
Mary      111.67
Elliot    102.40
Jane       48.55
.
.

Write a complete program on paper to read the information in this file and display 1) the name and amount for the person at Walmart who was carrying the least amount of money; and 2) the name and amount for the person at Boscov's who was carrying the least amount of money.

Notes:  You do not know how many people were surveyed at either store.  Obviously, the FAKE entry should not be regarded as representing valid data from either store.  If there is a tie in  terms of having the least amount, display the name of the first person with the least amount.  Don't worry about two people having the same first name.

You may work with one or two other students on this exercise.   I recommend that you write in English (or pseudocode or flowcharts or in a sketch) what needs to be done.  Then, put your ideas together into a C++ program through discussions with your partner(s).  Hand in your team's program on a sheet of paper - make sure to include all team member names and to write clearly.  You may use minimal comments in your program - a brief statement of purpose and the names of the partners is sufficient.  Otherwise, the program should be complete.
 

Possible Extra Credit:  Suppose that in addition to finding the least amount for each store we wanted to also find the average amount for each store.  How would the program change?   Do NOT change the program to do this; just provide a discussion describing the change.