Answer to Question #229030 in C++ for Onai Maxwell

Question #229030
Faculty member at the university demonstrates a lackadaisical attitude toward work. They seldom go to class yet at the end of each month they receive full salary. Management has decided that GHs 200, 300, 400, and 500 will be deducted from a faculty’s salary if he/she offends once, twice, third time and forth time respectively in a month. This means that if a faculty member offends once in a month GHs 200 will be
deducted, if a faculty member offends twice in a month, GHs 500 (i.e. 200+300)
will be deducted, if a faculty member offends three times in a month GHs 900
(i.e. 200+300+400), will be deducted and if a faculty member offends four times in a month GHs 1,400 (i.e.
200+300+400+500). Assuming all faculty
members are on a flat salary rate of GHs 2500.

a. Write a program to request for the names of four faculty members and
number times he/she has absented him/herself from class. One of them
should have absented him/herself once, another twice, another three times
and another four times.
1
Expert's answer
2021-08-24T07:21:15-0400


#include <iostream>


using namespace std;


int main()
{
    string names[4];
    int num[4];
    int ghs=2500;
    int ghs_d[4];
    cout<<"\nEnter the names of four faculty members and number of times absent:\n";
    for(int i=0;i<4;i++){
        cin>>names[i];
        cin>>num[i];
    }
    for(int i=0;i<4;i++){
        if(num[i]==1)
            ghs_d[i]=200;
        if(num[i]==2)
            ghs_d[i]=500;
        if(num[i]==1)
            ghs_d[i]=900;
        if(num[i]==1)
            ghs_d[i]=1400;
    }
    int total_ghs[4];
    for(int i=0;i<4;i++){
        total_ghs[i]=ghs-ghs_d[i];
    }
    for(int i=0;i<4;i++){
        cout<<"\nName: "<<names[i]<<" salary: "<<total_ghs[i];
    }
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS