Question
1) Partially filled arrays Copy-paste your code from warm-up 3 into a new file as a starting point for this problem. Modify your main() function
1) Partially filled arrays Copy-paste your code from warm-up 3 into a new file as a starting point for this problem. Modify your main() function to allow any number of names and heights to be entered (instead of just 2). You will need to use a partially filled array to do this. (You can assume that there will not be more than 100 people.)
My Code from warmup 3:
#include
string requestName(); double requestHeight(string fullName); int requestNumberOfPartners(); void printArray(string fullName[], double height[]);
int main(){ string fullName[2]; double height[2];
for(int i = 0; i < 2; i++){ fullName[i] = requestName(); height[i] = requestHeight(fullName[i]); } printArray(fullName, height); }
string requestName(){ string name; cout << "Please enter full name: "; getline(cin, name); return name; }
double requestHeight(string fullName){ double height; cout << "Please enter " << fullName << "'s height: "; cin >> height; cin.ignore(2, ' ');
return height; }
int requestNumberOfPartners(){ int numberOfPartners; cout << "How many partners are there?"; cin >> numberOfPartners;
return numberOfPartners; }
void printArray(string fullName[], double height[]){ cout << "If " << fullName[0] << " and " << fullName[1] << " stand on top of each other, their combined height will be " << (height[0] + height[1])<
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started