In this article, we are going to write a C++ program to calculate the salary of the servant. user will enter the hours of a servant and the rate per hour the servant gets. and program will display the total salary of the servant.

C++ program to calculate the salary of the servant


C++ program to calculate the salary of servent

#include<iostream>
#include<conio.h>


int main(void)
{

    int hours, rate, overtime, pay, opay, total;

    std::cout<<"Enter the hours of servant = ";
    std::cin>>hours;
    std::cout<<"Enter the rate per hour = ";
    std::cin>>rate;

    if(hours > 40)
    {
        overtime = hours-40;
        pay = 40*rate;
        opay = overtime*2*rate;
        total = pay+opay;
    }
    else
        total = hours*rate;

    std::cout<<"The total salary of the servant is = "<<total;

return 0;
}



Output

Enter the hours of servant = 5
Enter the rate per hour = 5
The total salary of the servant is = 25