So i need to create a win32 console program that basically asks a user to input certain information about random people...ie: height, shoe size, weight. after the user has entered the information for the first person, the user is then prompted to enter the same information for another person. eventually when the user is done entering the info for all the people, the program needs to output the averages of all the inputs (average height, weight, shoe size). It would make complete sense for me if i knew exactly how many people there were total, because i could define the variables separately for each person...but how can I program this so the user has the control of how many people are entered, but my program still prints out the correct average values?

It will give us a better idea if you could post your current code here or are you just asking for suggestions on this?

Edited 4 Years Ago by zeroliken: n/a

It will give us a better idea if you could post your current code here or are you just asking for suggestions on this?

I am just asking for suggestions as to how to go about it. I am trying to think of the best ways of doing it without using arrays or vectors cause we haven't gone over it in class. I want to have it mostly thought out first before I start writing the code.

Set a maximum of 100 people. I'm sure that's more than anyone simply testing your program will enter, and if they try to enter 101 a simple error message will prevent it.

Not exactly sure if my code is perfect (coding on the fly, here) but I believe this should work.

#include <iostream>
using namespace std;

int main()
{
	int max, height, shoeSize; weight, avgHeight, avgShoe, avgWeight;
         int sumHeight = 0, sumShoe = 0, sumWeight = 0;
	
	cout << "Please enter in the number of people you would like to enter data for: ";
	cin >> max;
	
	for(int i = 1; i <= max; i++)
	{
		cout << "Please enter in person " << i << "'s height: ";
		cin >> height;
		sumHeight += height;
		
		cout << "Please enter in person " << i << "'s shoe size: ";
		cin >> shoeSize;
		sumShoe += shoeSize;
		
		cout << "Please enter in person " << i << "'s weight: ";
		cin >> weight;
		sumWeight += weight;
	}
	
	avgHeight = sumHeight/max;
	avgShoe = sumShoe/max;
	avgWeight = sumWeight/max;
	
	cout << endl;
	cout << "The average height is: " << avgHeight << endl;
	cout << "The average shoe size is: " << avgShoe << endl;
	cout << "The average weight is: " << avgWeight << endl << endl;
	
	return 0;
}

Edited 4 Years Ago by yongj: Editing...

Comments
If you think it should work you shouldn't post it. We do NOT do homework for people. That's called CHEATING!!
This question has already been answered. Start a new discussion instead.