Answer to Question #212000 in C++ for Hemambar

Question #212000

Write a program to create a class HEIGHT with feet and inches as members. Write member

functions to READ, find the maximum height (MAX), find the mimimum height (MIN) and

average height (AVG) for arrays of object.


1
Expert's answer
2021-07-01T13:19:38-0400
/******************************************************************************
Write a program to create a class HEIGHT with feet and inches as members. Write member


functions to READ, find the maximum height (MAX), find the mimimum height (MIN) and


average height (AVG) for arrays of object.


*******************************************************************************/


#include <iostream>


using namespace std;
class HEIGHT{
    int feet;
    int inches;
    int height;
    int objs[10];
    public:
    void READ(){
        cout<<"\nEnter height: ";
        for(int i=0;i<10;i++){
            cin>>height;
            objs[i]=height;
        }
    }
    void MIN(){
        int min=objs[0];
        for(int i=0;i<10;i++){
            if (objs[i]<min)
                min=objs[i];
        }
        cout<<"\nMIN:"<<min;
    }
    void MAX(){
        int max=objs[0];
        for(int i=0;i<10;i++){
            if (objs[i]>max)
                max=objs[i];
        }
        cout<<"\nMAX:"<<max;
    }
    void AVG(){
        int sum=0;
        for(int i=0;i<10;i++){
            sum=sum+objs[i];
        }
        cout<<"\nAVG:"<<sum/10;
    }
    
};
int main()
{
    HEIGHT h;
    h.READ();
    h.MIN();
    h.MAX();
    h.AVG();


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS