Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

And here is an example of the program just like what I want to do I’m not really

ID: 3701835 • Letter: A

Question

And here is an example of the program just like what I want to do I’m not really sure how to d so please help me out lab is designed to give you practice working with arrays in C++. hireate a new Visual ++ project using your last name and Labl1 for the project (MooreN labl) and epp file name (Moorecpp). Add your name and class time to the header comments. For the lab you do not need to add further comments here but you should include inline comments and a comment with each function definition y the data file labi l txt from Canvas (Files ? 03 Lab Assignments) to your projec Then add the In the main function, declare an array called salaries that can hold 12 values of type double. code described below. For each function be sure to include the function prototype, function call statement and the function definition 3. a. Write a function called readSalaries to read in salaries from the file labl1.txt and store them in your salaries array. Declare the file variable, open, check the open success and close the file in this function Write a function called displaySalaries to display a list of the salaries stored in the array. Write another function called payRaise to give each employee a pay raise of 3 percent. For each employee, b. c. calculate the employee's new salary and replace the previous salary in the array. Call the function displaySalaries again to display a list of the new salaries. Bonus - 1 pt The data file contains salaries of employees from two locations, Cleveland and Cincinnati, d. e. with a Cleveland employee's salary first, followed by the salary of the Cincinnati employee with the same sition, the next Cleveland employee's salary and then a Cincinnati employee's salary and so on. Write a po function called totalSalaries that finds the sum of the salaries for the Cleveland employees (the salaries stored in elements 0, 2,4, etc.) and the sum of salaries for the Cincinnati employees (the salaries stored in elements 1, 3,5, etc.) as well as the total of all salaries. Print the totals with appropriate descriptions. Total salaries for cleveland employees$9999999 Total salaries for Cincinnati employees-$9999999 Total salaries for all employees

Explanation / Answer

CODE

#include <fstream>

#include <iostream>

using namespace std;

void readSalaries(double *, int);

void displaySalaries(double *, int);

void payRaise(double * , int);

void totalSalaries(double *, int);

int main()

{

    double salaries[12];

    readSalaries(salaries,12);

    displaySalaries(salaries, 12);

    payRaise(salaries,12);

    displaySalaries(salaries,12);

    totalSalaries(salaries,12);

    return 0;

}

void readSalaries(double * sal, int n){

    double *tempSal;

    tempSal = sal;

    int counter =1;

    ifstream infile;

    infile.open("lab11.txt");

   

    if(!infile){

        cout<<"Error reading file......"<<endl;

        exit(1);

    }

   

    while(counter <= n){

        infile>>*sal;

        counter++;

        sal++;

    }

}

void displaySalaries(double * disSal, int n){

    cout<<"Salaries:"<<endl;

    for(int i=0; i<n;i++){

        cout<<*disSal;

        disSal++;

    }

}

void payRaise(double * sl, int n){

    double *temp;

    temp = sl;

    for(int i=0; i<n;i++){

        *temp = *temp + (*temp *3 /100);

    }

}

void totalSalaries(double *s , int n){

    // Assuming salary stored in salaries array at alternate position

    int sumCle=0, sumCin=0,sumTotal;

    for(int i=0; i< n;i++){

        if(i%2 == 0){

            sumCle += *s;

            sumTotal += *s;

            s++;

        }else {

            sumCin += *s;

            sumTotal += *s;

            s++;

        }

    }

    cout<<"Total salaries for Cleveland Employees = $ "<<sumCle<<endl;

    cout<<"Total salaries for Cincinnati Employees = $ "<<sumCin<<endl;

    cout<<"Total salaries for all Employees = $ "<<sumTotal<<endl;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote