cs201 assignment no.1 2020 spring 2020

cs201 assignment no.1 2020 spring 2020

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 cs201@vu.edu.pk.

 

 

 

 

 

 

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.

 

 

 

 

Solution:

 

 

#include<iostream>

using namespace std;

 

int main(){

            int scale, initialSalary, incrementRate, taxDeductionRate;

            float incrementValue, taxValue, netSalary = 0;

           

            cout<<“*********** SALRY CALCULATOR **************\n”;

            cout<<“*******************************************\n”;

            cout<<“*********** ENTER 1 FOR SPS6  *************\n”;

            cout<<“*********** ENTER 2 FOR SPS7  *************\n”;

            cout<<“*********** ENTER 3 FOR SPS8  *************\n”;

            cout<<“*********** ENTER 4 FOR SPS9  *************\n”;

           

            cout<<“Select a payscale from the menu : “;

           

            cin>>scale;

            if(scale == 1){

                        initialSalary = 40000;

                        incrementRate = 20;

                        taxDeductionRate = 3;

            }else if(scale == 2){

                        initialSalary = 60000;

                        incrementRate = 15;

                        taxDeductionRate = 3;

            }else if(scale == 3){

                        initialSalary = 80000;

                        incrementRate = 10;

                        taxDeductionRate = 3;

            }else if(scale == 4){

                        initialSalary = 100000;

                        incrementRate = 5;

                        taxDeductionRate = 3;

            }else{

                        cout<<“You enter wrong scale\n”;

                        return 0;

            }

            incrementValue = ((initialSalary * incrementRate) / 100);

            taxValue = (((initialSalary + incrementValue) * taxDeductionRate) / 100);

            netSalary = (initialSalary + incrementValue) – taxValue;

            cout<<“Initial Salary : “<<initialSalary;

            cout<<“\nIncrement Amount : “<<incrementValue;

            cout<<“\nIncreased Salary : “<<initialSalary + incrementValue;

            cout<<“\nTex Deduction : “<<taxValue;

            cout<<“\nNet Salary : “<<netSalary;

}

You May Also Like

Leave a Reply

%d bloggers like this: