Answer to Question #240299 in C++ for Raven

Question #240299

A program uses a char variable named department and two double variables named salary and raise. The department variable contains one of the following letters (entered in either uppercase or lowercase): A, B, or C. Employees in departments A and B are receiving a 2% raise. Employees in department C are receiving a 1.5% raise. Write the C++ code to calculate and display the appropriate raise amount. Display the raise amount in fixed-point notation with two decimal places.


1
Expert's answer
2021-09-22T00:05:53-0400


#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    char department;
    double salary;
    double raise_amount;
    
    cout<<"Enter department of the employee: ";
    cin>>department;
    cout<<"Enter salary of the employee: ";
    cin>>salary;
    
    if(department == 'A' ||department == 'B')
    {
        raise_amount = (salary/100)*2;
    }
   
    else if(department == 'C')
    {
        raise_amount = salary/100*1.5;
    }
    
    cout<<"Raise amount: ";
    cout << setprecision(2) << fixed << raise_amount;
    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