Wednesday, May 20, 2020

CS201 Assignment 1 Solution with Explanation 2020 (Introduction to prog...





solution code here



=======================





#include <iostream>

using namespace std;

main(){

float initial_salary, updated_salary, net_salary , increRate;



float taxRate = 0.03;



int sps;





cout << "*** Select a pay scale from menu ***" <<endl;

cout << "****** Enter 1 for SPS6 ******" <<endl;

cout << "****** Enter 2 for SPS7 ******" <<endl;

cout << "****** Enter 3 for SPS8 ******" <<endl;

cout << "****** Enter 4 for SPS9 ******" <<endl;

cin >> sps;



cout << "SALARY CALCULATOR" <<endl;



if(sps == 1){

initial_salary = 40000;

increRate = 0.2;

updated_salary = initial_salary * (1 + increRate);  // 40000 * (1 + 0.2 = 1.2 or 40000 * 20 / 100 = 8000)  = 48000

net_salary = updated_salary * (1 - taxRate);        // 48000 * (1 - 0.03 = 0.97 or 40000 * 30 / 100 = 1440) = 46560

cout << "Initial Salary is " << initial_salary <<endl;  // 40000

cout << "Increment Amount is " << initial_salary * increRate <<endl; // 40000 * 0.2 = 8000

cout << "updated salary is " << updated_salary <<endl;  // 48000

cout << "Tax Deduction " << updated_salary * taxRate <<endl; // 1440

cout << "Net salary is " << net_salary <<endl;  // 46560

}



else if(sps == 2){

initial_salary = 60000;

increRate = 0.15;

updated_salary = initial_salary * (1 + increRate);

net_salary = updated_salary * (1 - taxRate);   

cout << "Initial Salary is " << initial_salary <<endl; 

cout << "Increment Amount is " << initial_salary * increRate <<endl;

cout << "updated salary is " << updated_salary <<endl;

cout << "Tax Deduction " << updated_salary * taxRate <<endl;

cout << "Net salary is " << net_salary <<endl;

   

}

else if(sps == 3){

initial_salary = 80000;

increRate = 0.1;

updated_salary = initial_salary * (1 + increRate);

net_salary = updated_salary * (1 - taxRate);   

cout << "Initial Salary is " << initial_salary <<endl; 

cout << "Increment Amount is " << initial_salary * increRate <<endl;

cout << "updated salary is " << updated_salary <<endl;

cout << "Tax Deduction " << updated_salary * taxRate <<endl;

cout << "Net salary is " << net_salary <<endl;

}

else if(sps == 4){

initial_salary = 100000;

increRate = 0.05;

updated_salary = initial_salary * (1 + increRate);

net_salary = updated_salary * (1 - taxRate);   

cout << "Initial Salary is " << initial_salary <<endl; 

cout << "Increment Amount is " << initial_salary * increRate <<endl;

cout << "updated salary is " << updated_salary <<endl;

cout << "Tax Deduction " << updated_salary * taxRate <<endl;

cout << "Net salary is " << net_salary <<endl;

}

else{

cout << "Selected choice is invalid" <<endl;

}

cout << "**********************************" <<endl;





}

No comments:

Post a Comment