create a menu driven application that accepts the salaries for ten employees and display the following information:
1)max salary
2)min salary
3)avg salary
4)number of employees whos salary is greater than 1000
5)the salaries in ascending and descending orders.

#include <iostream>

using namespace std;

class Max
{
    int marks[10];
    public:
    void max()
    {
        int m;
        for(m=0; m<10; m++)
        {
            cout<<"enter marks"<<endl;
            cin>>marks[m];
        }
     int com=0;
    while(com<9)
    {
     int temp;
     if(marks[com] < marks[com+1] )
    {
     temp=marks[com];
     marks[com]=marks[com+1];
     marks[com+1]=temp;
     com=0;
     continue;
    }
            com++;
    }
    }
    void disp()
     {
         int com=0;
         cout<<marks[com]<<"is the max number"<<endl;
     }
};
int main()
{
    Max A;
    A.max();
    A.disp();
    return 0;
}

i wrote this code which would accept values and store them in array and check for max number but i am not able to make it check for minimum number and the rest. i tried creating another method but it isn't working. :(

added few methods and it worked, so ill click this as resolved.

#include <iostream>

using namespace std;

class Max
{
    int marks[10];
    public:
    void max()
    {
        int m;
        for(m=0; m<10; m++)
        {
            cout<<"enter marks"<<endl;
            cin>>marks[m];
        }
     int com=0;
    while(com<9)
    {
     int temp;
     if(marks[com] < marks[com+1] )
    {
     temp=marks[com];
     marks[com]=marks[com+1];
     marks[com+1]=temp;
     com=0;
     continue;
    }
            com++;
    }
    }
    void disp()
     {
         int com;
         for(com=0;com<1;com++)
         {
         cout<<marks[com]<<"is the max number"<<endl;
         }
     }
     void disp1()
     {
         int com;
         for(com=9;com<10;com++)
         {
         cout<<marks[com]<<"is the min number"<<endl;
         }
     }
    void ascending()
    {
        int com;
        for(com=0;com<10;com++)
        {
            cout<<marks[com]<<endl;
        }
    }
    void descending()
    {
        int com;
        for(com=10;com>=0;com--)
        {
            cout<<marks[com]<<endl;
        }
    }
    void greater()
    {
        int com;
        for(com=0;com<10;com++)
        {
            if(marks[com]>1000)
            {
                cout<<marks[com]<<endl;
            }
        }
    }
};
int main()
{
    Max A;
    A.max();
    A.disp();
    A.disp1();
    A.ascending();
    A.descending();
    A.greater();
    return 0;
}

added few methods and it worked, so ill click this as resolved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.