Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CS 150 Spring 2012 Project 4 Due: Friday 3/30 at 11:59 p.m. This project require

ID: 3641174 • Letter: C

Question

CS 150 Spring 2012 Project 4
Due: Friday 3/30 at 11:59 p.m.


This project requires you to write a C++ program that will manage a list of data about health club members. To receive credit for this program, you must store the data using one array of structs. There will be no more than 35 items in the data file peeps.txt. Declare your array with 35 components.

A text file (peeps.txt)contains data about health club members. Each line contains data for one member formatted as follows:

<first name> <ID> <height in inches > <initial weight in pounds>

Data items are separated by banks. The name is a string; ID is an int; weight and height are both doubles. Input the data into an array of structs. Process the members until end of the file. After all data is input, print the list of members to the screen in labeled columns. Include name, ID, height, weight, and BMI.

A second text file (changes.txt) contains changes in weight for the club members. Each line contains an ID and a double representing the change in weight for the member with this ID. Input each line of data and record the loss or gain in the array component with the member

Explanation / Answer

#include //this program calculates the BMI of a person int main(int argc,char ** argv) { //mainline variable declarations FILE * output = stdout; FILE * input = stdin; int kg; int cm; int bmi; //prompt user for weight fprintf(output,"Enter weight in kg:");fflush(output); //input weight in kg fscanf(input,"%d",&kg); //prompt user for height fprintf(output,"Enter height in cms:");fflush(output); //input height in cms fscanf(input,"%f",&cm); //calculate BMI bmi = (kg/(cm)*(cm))*10000; //output results fprintf(output,"weight is %d",kg); fprintf(output,"height is %f",cm); fprintf(output,"BMI is %d. ",bmi); }