Question

In: Computer Science

Design a program that takes the height of 10 people (you need to take the heights...

Design a program that takes the height of 10 people (you need to take the heights and 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 Input should be be inputed Feet, inches and the output should also feet ,inches. This program should also have a loop as to provide the user with a way out of the program.


in c++ code please

Solutions

Expert Solution

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. If not, PLEASE let me know before you rate, I’ll help you fix whatever issues. Thanks

#include<iostream>

using namespace std;

int main(){
        //number of people
        const int size=10;
        //upper limit of average height of a jockey, change this as needed
        const int jockey_height=5*12 + 6; //5 ft 6 inches
        //upper limit of average height of an MLB player, change this as needed
        const int mlb_player_height=6*12 + 2; //6 ft 2 inches
        
        cout<<"Enter heights of "<<size<<" people:"<<endl;
        //initializing total height in inches to 0
        int heightSum=0, feet, inches;
        //looping for size times
        for(int i=1;i<=size;i++){
                //asking and reading height of current person in ft and inches
                cout<<"Enter height of person "<<i<<" (in feet and inches): ";
                cin>>feet>>inches;
                //converting input to inches and adding to heightSum
                heightSum+=feet*12+inches;
        }
        
        //finding average height in inches
        int heightAvg=heightSum/10;
        //converting average height in inches to ft and inches
        int avgHeightFeet=heightAvg/12;
        int avgHeightInches=heightAvg%12;
        //displaying it
        cout<<"Average height is "<<avgHeightFeet<<" ft "<<avgHeightInches<<" inches"<<endl;
        //now if average height is within the height limit of jockey, printing that they are
        //better suited to be Jockeys.
        if(heightAvg<=jockey_height){
                //<= 5 ft 6 inches
                cout<<"This group is better suited to be a group of Jockeys"<<endl; 
        }
        //if average height is within the height limit of MLB players, printing that they are
        //better suited to be MLB team.
        else if(heightAvg<=mlb_player_height){
                //>= 5 ft 6 inches and <= 6 ft 2 inches
                cout<<"This group is better suited to be an MLB Team"<<endl;        
        }
        //otherwise, better suited to be an NBA team.
        else{
                //> 6 ft 2 inches
                cout<<"This group is better suited to be an NBA Team"<<endl;
        }
        return 0;
}

/*OUTPUT*/

Enter heights of 10 people:
Enter height of person 1 (in feet and inches): 5 5
Enter height of person 2 (in feet and inches): 6 3
Enter height of person 3 (in feet and inches): 5 8
Enter height of person 4 (in feet and inches): 6 2
Enter height of person 5 (in feet and inches): 7 1
Enter height of person 6 (in feet and inches): 6 0
Enter height of person 7 (in feet and inches): 5 9
Enter height of person 8 (in feet and inches): 6 4
Enter height of person 9 (in feet and inches): 7 1
Enter height of person 10 (in feet and inches): 6 5
Average height is 6 ft 2 inches
This group is better suited to be an MLB Team

Related Solutions

C++: Design a program that takes the height of 10 people (you may take the heights...
C++: 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...
To study the relationship between height and the weight of people you know, you need to...
To study the relationship between height and the weight of people you know, you need to collect a sample of nine (9) people using a systematic sampling method. Where and how are you going to collect your sample? Collect the sample and record the data. Construct a confidence interval to estimate the mean height and the mean weight. (CLO 1) Find the sample mean and the sample standard deviation of the height. Find the sample mean and the sample standard...
A sample of 10 employee’s height is taken to design the height of doorway. The measurements...
A sample of 10 employee’s height is taken to design the height of doorway. The measurements (in cm) are in the following table 167.87 153.24 150.39 173.38 177.91 155.88 171.06 155.57 171.43 178.62 What should be the height of the doorway if you want that just a 0.1% of the employees have troubles passing through it? You think that the initial 10-employee sample is too small and you want to ensure a confidence level of 97% with an error in...
I need someone to create a program for me: Create a program that takes as input...
I need someone to create a program for me: Create a program that takes as input an employee's salary and a rating of the employee's performance and computes the raise for the employee. The performance rating here is being entered as a String — the three possible ratings are "Outstanding", "Acceptable", and " Needs Improvement ". An employee who is rated outstanding will receive a 10.2 % raise, one rated acceptable will receive a 7 % raise, and one rated...
Design and implement a program in python that takes a list of items along with quantities...
Design and implement a program in python that takes a list of items along with quantities or weights. The program should include at least two function definition that is called within the main part of your program. Each item has a price associated by quantity or weight. The user enters the item along with the quantity or weight and the program prints out a table for each item along with the quantity/weight and total price. Your program should be able...
. 1. Take a survey of 10 people. Ask them if they take ibuprofen for headaches....
. 1. Take a survey of 10 people. Ask them if they take ibuprofen for headaches. Name yes/no 1. ________________________ ____________________ 2. ________________________ ____________________ 3. ________________________ ____________________ 4. ________________________ ____________________ 5. ________________________ ____________________ 6. ________________________ ____________________ 7. ________________________ ____________________ 8. ________________________ ____________________ 9. ________________________ ____________________ 10. ________________________ ____________________ 2. Determine the probability that someone uses ibuprofen for pain, using the results of your experiment. ___________________________ __ 3. Using the percentage from your experiment, draw a binomial distribution chart for a...
What appropriate and necessary actions do you need to take to advise relevant people where there...
What appropriate and necessary actions do you need to take to advise relevant people where there is poor performance?  Please outline the process and refer to the relevant legislation.
Describe why people become entrepreneurs and what it takes, personally? What does it take to succeed?
Describe why people become entrepreneurs and what it takes, personally? What does it take to succeed?
Suppose you collect data on people’s height from a sample of 100 people. The average height...
Suppose you collect data on people’s height from a sample of 100 people. The average height in the sample is 66, and the standard deviation of the sample meanis 3 inches. Calculate the 95% confidence interval for the average height in the population At the 12% significance level, test the hypothesis that the average height in the population is 69 inches. Use the four steps we discussed in class. Calculate the p-value for the hypothesis that the average height in...
I need to design and implement a JAVASCRIPT program that will allow us to determine the...
I need to design and implement a JAVASCRIPT program that will allow us to determine the length of time needed to pay off a credit card balance, as well as the total interest paid. The program must implement the following functions: displayWelcome This function should display the welcome message to the user explaining what the program does. calculateMinimumPayment This function calculates the minimum payment. It should take balance and minimum payment rate as arguments and return the minimum payment. So...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT