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

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.

Edited 1 Year Ago by Moschops

Comments
i have to write this 100 times ?

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.

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.

This article has been dead for over six months. Start a new discussion instead.