Bella Pearson
2012-10-12 11:49:53 UTC
(a) Sex code: “m” or “f”
(b) Age (in years)
(c) Height (in inches)
(d) Weight (in pounds)
Write a program that produces a report in the following format:
Average Height / Weights for the Sample Population
Average Height Average Height Average Weight Average Weight
Age for Men (in) for Women (in) for Men (lb) for Women (lb)
------------ -------------- -------------- -------------- --------------
0-18 XX.X XX.X XXX.X XXX.X
19-35 XX.X XX.X XXX.X XXX.X
36 and over XX.X XX.X XXX.X XXX.X
Round all averages to the nearest tenth. Use nested if....else constructs (not repeated ifs) in this program.
Also use good programming techniques: meaningful variable names, meaningful comments, and proper indentation.
All input should come from an input file and all output should go to an output file named using your name plus the ".txt" extension. Use eof indicator to terminate input from the input file. You are to submit your .cpp source file.
Here is the input, which you copy / paste to your input file. I suggest you name it "input.txt".
m 13 52 89
m 18 72 160
f 18 62 112
f 31 65 125
f 65 60 150
m 63 67 145
f 49 67 155
m 40 80 267
m 25 78 302
f 45 70 172
f 27 72 188
f 20 66 132
m 20 68 180
f 50 58 133
m 42 64 129
m 47 67 201
f 36 63 140
m 8 48 75
f 24 68 163
m 36 66 212
f 29 65 137
f 12 46 95
m 41 74 198
In C++