Professional Documents
Culture Documents
Fall 2022 - CS201 - 1
Fall 2022 - CS201 - 1
Fall 2022 - CS201 - 1
1 Total Marks: 20
Assignment
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 Utility Allowance
salary)
1 50000 10 3000
2 70000 10 5000
3 90000 10 7000
If the user enters input other than 1, 2 and 3. Then program should prompt the user to enter the
correct scale of the employee again.
The Code:
#include<iostream>
main()
{
int scale=0;
int salary,rent,allowance;
jump:
cout<<"Enter the scale of the employee (1 to 3)"<<endl;
cin>>scale;
switch(scale)
{
case 1:
salary=50000;
allowance=3000;
cout<<"The Basic Salary is : "<<50000<<endl;
rent=salary/10;
cout<<"The House Rent is : "<<rent<<endl;
cout<<"The Utility allowance: "<<allowance<<endl;
cout<<"Net Payable Salary is : "<<50000+rent+allowance<<endl;
break;
case 2:
salary=70000;
allowance-5000;
cout<<"The Basic Salary is : "<<70000<<endl;
rent=salary/10;
cout<<"The House Rent is : "<<rent<<endl;
cout<<"The Utility allowance: "<<allowance<<endl;
cout<<"Net Payable Salary is : "<<70000+rent+allowance<<endl;
break;
case 3:
salary=90000;
allowance=7000;
cout<<"The Basic Salary is : "<<90000<<endl;
rent=salary/10;
cout<<"The House Rent is : "<<rent<<endl;
cout<<"The Utility allowance: "<<allowance<<endl;
cout<<"Net Payable Salary is : "<<90000+rent+allowance<<endl;
break;
default:
cout<<"Incorrect Range..."<<endl;
goto jump;
}