Header Ads

Write a C++ program to prompt the user to enter the Scale and then print the Employee’s Basic Pay, House Rent Allowance and Total Pay by using a function.

Write a C++ program to prompt the user to enter the Scale and then print the Employee’s Basic Pay, House Rent Allowance and Total Pay by using a function.

 

Calculations are given as:

Scale

Salary

House Rent(% of salary)

Utility Allowance

1

50000

10

3000

2

70000

10

5000

3

90000

10

7000






Program:

#include <iostream>

using namespace std;


int employee(int scale){

    int salary, houseRent, allowance, totalPay;

    switch(scale)

    {

        case 1:

            salary = 50000;

            houseRent = salary * 10/100;

            allowance = 3000;

            totalPay = salary + houseRent + allowance;

            cout<<"The Basic Salary is     : "<< salary<<"\n"

                <<"The House Rent is       : "<<houseRent<<"\n"

                <<"The Utility Allowance is: "<< allowance<<"\n"

                <<"Net Payable Salary is   : "<< totalPay;

            break;

        case 2:

            salary = 70000;

            houseRent = salary * 10/100;

            allowance = 5000;

            totalPay = salary + houseRent + allowance;

        cout<<"The Basic Salary is     : "<< salary<<"\n"

                <<"The House Rent is       : "<<houseRent<<"\n"

                <<"The Utility Allowance is: "<< allowance<<"\n"

                <<"Net Payable Salary is   : "<< totalPay;

            break;

        case 3:

            salary = 90000;

            houseRent = salary * 10/100;

            allowance = 7000;

            totalPay = salary + houseRent + allowance;

            cout<<"The Basic Salary is     : "<< salary<<"\n"

                <<"The House Rent is       : "<<houseRent<<"\n"

                <<"The Utility Allowance is: "<< allowance<<"\n"

                <<"Net Payable Salary is   : "<< totalPay;

            break;

        default:

            cout<<"Incorrect Range... "<<"\n"<<"Enter the scale of employee(1-3)";

            break;

    }

    

}

int main() {

    int scale;

    cout << "Enter your scale (1-3): ";

    cin >> scale;

    employee(scale);

    return 0;

}


OUTPUT


If enter "1"

If enter "2"

If enter "3"


If enter "any other number"









No comments

Powered by Blogger.