Question

In: Computer Science

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 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

-incorporate an array in collecting your data.

-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

Solutions

Expert Solution

#include<iostream>
#include<math.h>
using namespace std;

int main()
{
    char ch;
    float heights[10],sum=0.0,avg,average_height;
    int i,feet,inches;
    do
    {
        cout<<"Enter the height in inches of a group of 10 students : "<<endl;;
        for(i=0;i<10;i++)       //Taking input of heights of 10 persons
            cin>>heights[i];
        for(i=0;i<10;i++)
            sum=sum+heights[i];
        avg=sum/10;
        average_height=avg*0.08333;
        feet=(int)average_height;       //Average height in feet and inches
        inches=ceil(average_height-feet);   //ceil function is defined in the library header file math.h
        cout<<"The average height of the group of 10 students is : "<<feet<<" feet "<<inches<<" inches"<<endl;
        if(avg>=73)
           cout<<"The group is best suited to be an MLB team "<<endl;
        else if(avg>=70 && avg<73)
           cout<<"The group is best suited to be a NBA team "<<endl;
        else
            cout<<"The group is best suited to be on the team of jockeys"<<endl;
        cout<<"Press 'y' to enter another set of heights or '#' to quit : ";        //A way out of the program
        cin>>ch;
    }while(ch!='#');
    return 0;
}

The output of the code is :

PLEASE LIKE THE ANSWER IF YOU FIND IT HELPFUL OR YOU CAN COMMENT IF YOU NEED CLARITY / EXPLANATION ON ANY POINT.


Related Solutions

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...
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...
Write a C++ program that takes 4 readings of temperature, each reading is between -10 and...
Write a C++ program that takes 4 readings of temperature, each reading is between -10 and 55. The program should: • Computes and print out the average temperature (avgTemp), maximum temperature (maxTemp) and minimum temperature (minTemp) of the day. • The program should also compute and print out the number of temperature readings (numTemp) that exceed 35. • Enforce validation on the user input (using while loop) and use appropriate format for the output. The average temperature should be rounded...
Take the Java program Pretty.java and convert it to the equivalent C program. You can use...
Take the Java program Pretty.java and convert it to the equivalent C program. You can use the file in.txt as sample input for your program. v import java.io.*; import java.util.*; public class Pretty { public static final int LINE_SIZE = 50; public static void main(String[] parms) { String inputLine; int position = 1; Scanner fileIn = new Scanner(System.in); while (fileIn.hasNextLine()) { inputLine = fileIn.nextLine(); if (inputLine.equals("")) { if (position > 1) { System.out.println(); } System.out.println(); position = 1; } else...
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...
Convert the C program shown below to MIPS program. You may choose the $t registers, but...
Convert the C program shown below to MIPS program. You may choose the $t registers, but must correctly apply the $a and $v registers used in function calls. Please do not include an exit syscall in your MIPS solution. Hint: review jr and jal instructions. int fun( int a, int b ) { if ( a >= b ) return b + 2*a; else return b + a; } void main() { } int a = 10; int b =...
Does knee height predict overall height? Since elderly people may have difficulty standing to have their...
Does knee height predict overall height? Since elderly people may have difficulty standing to have their heights measured, a study looked at predicting overall height (y) in centimeters, from height to the knee (x) in centimeters. Use this data to answer the following questions. Data looking at knee height (in cm) and overall height (in cm) Knee Height (cm) 57.70 47.40 43.50 44.80 55.20 54.60 Overall Height (cm) 192.10 153.30 146.40 162.70 169.10 177.80 What is the mean x and...
Does knee height predict overall height? Since elderly people may have difficulty standing to have their...
Does knee height predict overall height? Since elderly people may have difficulty standing to have their heights measured, a study looked at predicting overall height (y) in centimeters, from height to the knee (x) in centimeters. Use this data to answer the following questions. Data looking at knee height (in cm) and overall height (in cm) Knee Height (cm) 57.70 47.40 43.50 44.80 55.20 54.60 Overall Height (cm) 192.10 153.30 146.40 162.70 169.10 177.80 What is the mean x and...
1. Write a program in C++ that takes as inputs a positiveinteger n and a...
1. Write a program in C++ that takes as inputs a positive integer n and a positive double a. The function should compute the geometric sum with base a up to the powern and stores the result as a protected variable. That is, the sum is: 1 + ? + ? ^2 + ? ^3 + ? ^4 + ⋯ + ? ^?2.  Write a program in C++ that takes as input a positive integer n and computes the following productsum...
. 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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT