Fall 2022 - CS201 - 1

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Assignment No.

1 Total Marks: 20

Semester: Fall 2022 Due Date: 05th


December 2022
CS201 – Introduction to Programming

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

As a result, you should have the following output:


If the user enter 1:

If the user enter 2:

If the user enter 3:

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>

using namespace std;

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;
}

You might also like