A company has 100 employees who receive a monthly salary
ranged from 1000QR to 50000QR. We can represent the
employee by an array of 100 elements as follows:
double MonthS[100];
Q1: Write a for loop to fill-in the array with data.
Q2: Calculate the average salary of employees.
Q3: Find the employee number who gets the maximum salary.
Q4: Count the number of employees who gets a monthly salary
between 10000QR and 25000QR.
Q5: Decrease the salary of employees who receive the maximum
payment per month by 5000QR.
Q6: The array B represents the extra hours done by every
employee during the month. The rate per hour is 50QR for
those who get between 10000QR and 20000QR. It is 75QR
otherwise. Updated then the salary of all employees based on
the numbers of extra hours worked.
Q7: Print a histogram showing every employee number and
his/her salary.
Q8: Add a Bonus of 6.4% to every employee who worked more
than 15 extra hours in a month (Use the array B to find the extra
hours and update then the Array A).

Start at the beginning.

Q1: Write a for loop to fill-in the array with data.

So write a program that creates the array, and when that is working, add a for loop to fill the array with data.

Do you know how to write an empty program that does nothing?
Do you know how to create an array?
Do you know how to write a for loop?

for (int x=0;x<=100;x++)
    {
        MonthS[x]= 1000 && MonthS[x]<=50000;  
        cout<<x<<"--------" <<MonthS[x]<<endl;
    }
 is this corerect ? 
#include <iostream>
using namespace std;
int main ()
{
    double avg,sum;
    double MonthS[100];
    int x,count,employee;
    int max,salarymax;
    count=0;
    max=MonthS[0];
    avg =0;
    sum=0;
    cout<<"empoloyee nymber ----- salary " << endl;
    for (int x=0;x<=100;x++)
    {
        MonthS[x]= 1000 && MonthS[x]<=50000;  
        cout<<x<<"--------" <<MonthS[x]<<endl;
    }
    sum+=MonthS[x];
        avg=sum/100;
        cout<<"avg="<<avg<<endl;
        {
for (int x=0;x<=100;x++)
        if (MonthS[x] > max) 
            max = MonthS[x];
cout << max<<"is the maximum:" << endl;
max=max-50000;
cout << "salary of employee who recieve the max"<<salarymax<< endl;
        }
                {
for (int x=0;x<=100;x++)
        if (MonthS[x] <=25000 && MonthS[x] >=10000) 
            count++;
cout <<"no.of employees"<<employee<< endl;
    return 0;
}

i made this ! is the question need each part seperately ?
i couldn't complete the rest !
can u just check it ? and give me an idea how to complete it ! i would be thankful ")

MonthS[x]= 1000 && MonthS[x]<=50000;

This makes no sense. What are you trying to do?

to input the salary that is only between 1000- 50000

You have to tell it what number to put in each element of the array.

MonthS[x]= 1000 This puts the number 1000 into array element x. If you want each element to have a different number, you'll have to change that number for each element.

commented: i have to write this 100 times ? +0

i have to write this 100 times ?

If you didn't use a number, but a variable, you could change the variable each time the loop goes round.

i did'nt get it ! :/
can u just show an example to me ?

Assume the individual data has to come from the user via cin.

Here is how to make a number change every time the loop goes round.

int x = 1000;
for (int loop_counter=0; loop_counter<100; loop_counter++)
{
  x = x+1000;
}

Now combine that with filling the array.

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.