Question

In: Computer Science

C++ employees entering data for a report (or entering into a db, etc.) this section of...

C++

employees entering data for a report (or entering into a db, etc.)

this section of code will also calculate their average salary of all the entered salary amounts.

This example will use a for loop for a user given number of employees, and a nested do..while loop to enter salary information. Then find the average salary for all the entered values.

Solutions

Expert Solution

C++ program to find the average salary of employees.

Steps:

  • Number of salaries have to be entered
  • find the sum of the salaries
  • Find the average of the salaries

Source code:


#include<iostream>
using namespace std;
 
int main()
{
    int i,n,x,sum=0;
    float avg;
 
    cout<<"How many numbers of salaries have to entered : ";
    cin>>n;
    
 
 
    for(i=1;i<=n;++i)
    {
        cout<<"\nSalaries "<<i<<" :: ";
        cin>>x;
 
        sum+=x;
    }
 
    avg=(float)sum/(float)n;
 
    cout<<"\n\nSum of "<<n<<" salary :: "<<sum;
 
    cout<<"\n\nAverage of "<<n<<" total salaries :: "<<avg;
 
    cout<<"\n";
 
    return 0;
}

The output

How many number of salaries have to enter : 3

Salaries 1 :: 45000

Salaries 2 :: 15000

Salaries 3 :: 40000


Sum of 3 salary :: 100000

Average of 3 total salaries :: 33333.3



Related Solutions

To what extent are the employees in a team/ section/ division responsible for: Data collection to...
To what extent are the employees in a team/ section/ division responsible for: Data collection to support the budget? Developing realistic and attainable budgets for the section/ division? Monitoring expenditure? Using the budget to measure actual work against projected work achievements?
Target handles a lot of data from many different sources (customers, vendors, suppliers, employees, etc.). The...
Target handles a lot of data from many different sources (customers, vendors, suppliers, employees, etc.). The concept of Big Data is a concern for such companies. Answer the following questions: What was the weakness behind the Target data breach? Were third parties involved? How did Target run its POS system? How could it be prevented? How much does human error come into play with big enterprise security breaches? What are some challenges in Big Data with regards to security?
1. Given the data definitions, W DW 1234 A DB 23 B DB -12 2. what...
1. Given the data definitions, W DW 1234 A DB 23 B DB -12 2. what is displayed by the DOS display string call mov dx, OFFSET Msg mov ah, 9h int 21h
Consider the following data set regarding six company employees who report to the same manager in...
Consider the following data set regarding six company employees who report to the same manager in a local office: Employee A Birth Place B Monthly Salary (Nearest Dollar) C Current Rating D Rating Score (1.0 – 5.0) E Driving Distance Residence to Office (Miles) F Parking Permits Issued Sue Williamsburg, VA 2,916 Meets 3.2 2.3 1 Fred Boone, NC 2,500 Below 1.8 20.2 1 Mark Key West, FL 1,000 Meets 2.9 0.5 0 Dontay Smugglers Notch, VT 2,000 Exceeds 4.3...
This exercise just lets you focus on data types, statements, etc. in C# to ease you...
This exercise just lets you focus on data types, statements, etc. in C# to ease you into the language. This exercise is designed to allow you to focus on the data types that are appropriate for attributes of real- world objects. Later, you will start to combine these attributes with behaviors (methods) and then transition them into object-oriented classes. Also, this exercise does not give explicit instructions on every field required. You will be required to think through the attributes...
A space is to be maintained at 26°C DB and 50% RH at a location where...
A space is to be maintained at 26°C DB and 50% RH at a location where the summer design conditions are 35°C DB and 27°C WB. In the system, 30% fresh air is used for the comfort of occupants. The cooling coil in the AHU has an apparatus dew point temperature of 9.5°C, and a by-pass factor of 0.25. The fan, supplying 36,000 m3/h air, in the AHU has a motor with an electricity consumption rate of 32 kW. Assuming...
write a one small report or describe ( defention , types etc ... ) these three...
write a one small report or describe ( defention , types etc ... ) these three in surveying 1- longitudinal profiles 2- cross sections 3- contour maps more than a hundred words
Is unionization a good thing or a bad thing for employees, business, the economy, society, etc.?...
Is unionization a good thing or a bad thing for employees, business, the economy, society, etc.? 1. Present both sides of the argument. Use information from the text and other course documents to support your arguments (topics should include the efficiency, equity, and voice triad; the four schools of labor relations; and other information from the book and course document.) 2. Based on the two arguments above, discuss your opinion of the efficacy (effectiveness) of the labor movement and if...
Demand can be estimated with experimental data, time-series data, or cross-section data. In this case, cross-section...
Demand can be estimated with experimental data, time-series data, or cross-section data. In this case, cross-section data appear in the Excel file. Soft drink consumption in cans per capita per year is related to six-pack price, income per capita, and mean temperature across the 48 contiguous states in the United States. TABLE 1.  SOFT DRINK DEMAND DATA State Cans/Capita/Yr 6-Pack Price ($) Income/Capita ($1,000) Mean Temp. (F) Alabama 200 3.19 35.1 66 Arizona 150 2.99 45.9 62 Arkansas 237 2.93 29.7...
Demand can be estimated with experimental data, time-series data, or cross-section data. In this case, cross-section...
Demand can be estimated with experimental data, time-series data, or cross-section data. In this case, cross-section data appear in the Excel file. Soft drink consumption in cans per capita per year is related to six-pack price, income per capita, and mean temperature across the 48 contiguous states in the United States. Given the data, please construct the demand estimation for soft drink consumption in the United States by (1) a multiple-linear regression equation, and (2) a log-linear (exponential) regression equation...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT