231k views
1 vote
Design a program that takes the height of 10 people you may take the heights in inches) and calculates average height. Based on the average height of these 10 people, determine if this group is better suited to be an MLB team, NBA team, or a group of Jockeys (e.g. Kentucky Derby). The program is to be user friendly, meaning it is to be used by someone who has never programed. This program is to loop with a 'way out." "Way out" meaning, a way to shut the program down without closing the window. And, when I mean by loop, I mean the program just restarts after analyzing the first 10 people. Other requirements -demonstrate the use of if statements -demonstrate the use of a loop or loops (if necessary) -round to whole numbers output the average height in feet and inches the average Notes: -Due tonight -You'll need to research the heights of these professional sports. -You'll be submitting source code (i.e..doc file) & screenshot of your program running ITS A C++ CLASS AND THE HEIGHT SHOULD BE IN INCHES

User Jim C
by
8.1k points

1 Answer

5 votes

Final answer:

A C++ program is designed to calculate the average height of 10 people and assess their suitability for MLB, NBA, or Jockey sports teams, using if statements and a loop with a user-friendly exit option.

Step-by-step explanation:

To create a program to calculate the average height of 10 people and suggest which sports team they would best fit, we need to use a combination of data collection, conditional logic (if statements), and looping structures. To gather the data, you would prompt the user to input the height of each person, one at a time. The collected heights would be added together and then divided by the number of people to find the average. Research on professional sports height averages would inform thresholds for the MLB, NBA, or Jockeys' suitability. The program should offer a 'way out' or exit option after each loop to prevent forcing a window close.

Regarding outliers and statistics such as mean and standard deviation, those would not be directly calculated in this program. However, in the field of statistics, these concepts are crucial for understanding data distributions and making predictions. For example, calculating the z-score for a given height can determine how unusual that height is within the context of basketball players' heights.

Sample Code

#include
using namespace std;

int main() {
bool continueRunning = true;
while (continueRunning) {
int sumOfHeights = 0, height;
for (int i = 0; i < 10; ++i) {
cout << "Enter height for person " << i+1 << ": ";
cin >> height;
sumOfHeights += height;
}
int avgHeight = sumOfHeights / 10;

// Assuming research thresholds here, can be adjusted
if (avgHeight > 75) { // NBA average height
cout << "This group suits NBA.";
} else if (avgHeight > 66 && avgHeight <= 75) { // MLB average height
cout << "This group suits MLB.";
} else { // Jockey average height
cout << "This group suits being Jockeys.";
}

cout << "\\Do you want to run the program again? (0 for no, 1 for yes) ";
cin >> continueRunning;
}
return 0;
User Paul Van Dyk
by
8.6k points

No related questions found