Home‎ > ‎Assignments‎ > ‎

Your Loss Our Gain

Programming Assignment

The Get-Rich-Quick Weight Loss Center awards a prize annually to the client who has lost the most weight. The record of each client contains the following information:

  • name
  • "before" weight in pounds
  • "after" weight in pounds

 

You are to write a program that finds the client who has lost the most weight this past year, and who will therefore be awarded the prize. Also find the client who has lost the least weight. You may assume that nobody has actually gained weight, and that there are no ties. Read client data without assuming a fixed number of clients (use a sentinel value to end the input data). Use the following 3 datasets to test your program.

Data Set #1
 Name TomMike Jenny Ryan Mason Joan Wendy
 Before 210 205 190 175 177 165 183
 After 145 178 190 150 160 143 169
Data Set #2
 Name LeonKevinKay Irene Mason Abby Bill Sophie Kelly Lily
 Before 173 201 153 144 198 164 196 130 153 160
 After 168 175 132 125 151 146 175 109 140 142
Data Set #3
 Name JonsonLee Jennifer Keen Leon Tina Donna Tommy Dora Cindy Neo
 Before 185 179 141 230 165 125 114 176 165 135 184
 After 173 176 132 178 134 101 98 162 130 110 160

 

THE FOLLOWING INSTRUCTIONS MAY BE HELPFUL IF YOU ARE HAVING TROUBLE WITH THIS ASSIGNMENT.

Do your assignment in the following stages:

A. HW A - Write a program that will read client data; compute the weight loss for each client; and output the maximum weight lost.

B. HW B - Modify program A. In addition to displaying the maximum weight loss over all clients, also output the name of the client who lost the most weight and print a message of congratulations to the winner. Use the <string> class library.

C. HW C - Modify program B. Also display the name of the client who lost the least weight, and print an appropriate comforting message.

Comments