# CS201 Assignment 1 Solution and Discussion

• ``````Assignment No.  1
``````

Semester: Spring 2020
CS201 – Introduction to Programming Total Marks: 20

Due Date: 01/06/2020
Instructions
Please read the following instructions carefully before submitting assignment:
It should be clear that your assignment will not get any credit if:

o Assignment is submitted after due date.
o Submitted assignment does not open or file is corrupt.
o Assignment is copied (From internet/students).

Recommended tool to develop Assignment

• Dev C++

Objectives:
To enable students to understand and practice the concepts of:
• Data Types and Variables
• Arithmetic and Logical Operators
• If-else and switch case statements

Assignment Submission Instructions
You have to submit only.cpp file on the assignments interface of CS201 from your LMS account. Assignment submitted in any other format will not be accepted and will be scaled with zero marks.

For any query related to assignment, please contact [email protected].

Assignment

Create a menu based program using C++ which will calculate the increment and tax deduction amount on salary based on the pay scale of an employee. After this, net salary of employee will be calculated. Details of these calculations are provided in Solution Guidelines.

You are required to use initial salary, increment rate, and tax deduction rate given in following table for each of the given pay scale.

 Pay Scale Initial Salary Increment Rate Tax deduction Rate SPS6 40,000 20% 3% SPS7 60,000 15% 3% SPS8 80,000 10% 3% SPS9 100,000 5% 3%

Solution Guidelines:
• There should be a menu consisting of different pay scales and options to select any one pay scale. See first sample screenshot for reference.
• On the basis of a selected pay scale, calculate increment amount and tax deduction amount. For the rate of increment and tax, use the table given above.
• Increment amount will be calculated through initial salary on the basis of given rate.
• Updated salary will be calculated as initial salary plus incremented amount.
• Tax deduction amount will be calculated through updated salary as per given rate.
• Formula to calculate net salary is Net Salary = Initial Salary – Incremented Amount – Tax Deduction Amount
• After doing all necessary calculations, display initial salary, incremented amount, increased (updated) salary, tax deduction amount and net salary. See last sample screenshot for reference.

Sample Screenshots of Output:

Screenshot of selecting invalid choice of pay scale from menu.

Screenshot to display all calculated values on screen.

Lectures Covered: (Lecture # 1- 8) and Due date to submit solution: (Monday, June 01, 2020).

• ``````#include <iostream>
#include <stdlib.h>
using namespace std;

main() {
int choice = 0, salary = 0;
float increment = 0.0, tax = 0.0, newsal = 0.0;

cout<<"\n ********* SALARY CALCULATOR *********\n"<<endl;
cout<<" *************************************\n"<<endl;
cout<<" ********* Enter 1 for SPS6  *********\n"<<endl;
cout<<" ********* Enter 2 for SPS7  *********\n"<<endl;
cout<<" ********* Enter 3 for SPS8  *********\n"<<endl;
cout<<" ********* Enter 4 for SPS9  *********\n"<<endl;

cout<<" Select a pay scale from the menu: ";
cin>>choice;

switch(choice){
case 1:
salary = 40000;
increment = salary * 20/100;
newsal = salary + increment;
tax = newsal * 3/100;
break;
case 2:
salary = 60000;
increment = salary * 15/100;
newsal = salary + increment;
tax = newsal * 3/100;
break;

case 3:
salary = 80000;
increment = salary * 10/100;
newsal = salary + increment;
tax = newsal * 3/100;
break;

case 4:
salary = 100000;
increment = salary * 5/100;
newsal = salary + increment;
tax = newsal * 3/100;
break;

default:
cout<<" Selected choice is invalid."<<endl<<endl;
}

if(choice >= 1 && choice <=4) {
cout<<" Initial Salary: "<<salary<<endl;
cout<<" Incremented Amount: "<<increment<<endl;
cout<<" Increased Salary: "<<newsal<<endl;
cout<<" Tax Deduction: "<<tax<<endl;
cout<<" Net Salary: "<<newsal-tax<<endl<<endl;
}

system("pause");
}

``````

• Official Channel of the Cyberian.pk
Please Like us fb: http://bit.ly/2laGweN

How to Copy NEW Quiz in VU Exam
Chrome Extension Link: http://bit.ly/31LSltr

Video: http://bit.ly/31LSltr

#it430 #Quiz , #Assignment, #GdB #Solution and #discussion #Spring2020

1

4

3

1

5

8

1

2
| |