I want c++ code for employee payslip calculation using switch statement
convert this code to switch statement also, use for loop
___________________________________________________________________________
#include
using namespace std;
int main()
{char empname[222];
float basicSalary, h_r_a, DearnessAllow, tax, netSalary;
int e_id;
cout<<"\nEmployee Name :";
cin>>empname;
cout<<"\nEmployee Id :";
cin>>e_id;
cout << "Enter Basic Salary : ";
cin >> basicSalary;
DearnessAllow = 0.30 * basicSalary;
h_r_a= 800;
tax = 0.10 * basicSalary;
netSalary = basicSalary + DearnessAllow + h_r_a - tax;
cout<<"\nEmployee Id : "<
cout<<"\nEmployee Name : "<
cout<<"\nBasic Salary : "<
cout<<"\nHRA : "<
cout<<"\nDearnessAllow : "<
cout<<"\nTax : "<
cout<<"\nNet Salary : "<
return 0;
}
I have written the code using switch statement and also used for loop please consider it .
Code :
#include<bits/stdc++.h>
using namespace std;
int main()
{
char repeat = 'Y';
for (;repeat == 'Y';){
char empname[222];
float basicSalary, h_r_a, DearnessAllow, tax, netSalary;
int e_id;
cout<<"\nEmployee Name :";
cin>>empname;
cout<<"\nEmployee Id :";
cin>>e_id;
cout << "Enter Basic Salary : ";
cin >> basicSalary;
DearnessAllow = 0.30 * basicSalary;
h_r_a= 800;
switch (1)
{
case 1:
if (basicSalary <= 2,50,000)
tax = 0;
case 2:
if (basicSalary > 250000 && basicSalary <=
500000)
tax = 0.05*basicSalary;
case 3:
if (basicSalary > 500000 && basicSalary <=
1000000)
tax = (0.12)*(basicSalary - 500000) + 12500;
case 4:
if (basicSalary > 1000000)
tax = 1,12,500 + 0.30*1000000;
}
netSalary = basicSalary + DearnessAllow + h_r_a - tax;
cout<<"\nEmployee Id : "<<e_id<<endl;
cout<<"\nEmployee Name : "<<empname<<endl;
cout<<"\nBasic Salary : "<<basicSalary<<endl;
cout<<"\nHRA : "<<h_r_a<<endl;
cout<<"\nDearnessAllow : "<<DearnessAllow<<endl;
cout<<"\nTax : "<<tax<<endl;
cout<<"\nNet Salary :
"<<netSalary<<endl;
cout<<"Do you want to still
continue....Y/N"<<endl;
cin>>repeat;
}
return 0;
}
Screen shots of the code :
![#include<bits/stdc++.h> using namespace std; int main() { char repeat = Y; for (; repeat == Y;) { char empname [222]; flo](http://img.homeworklib.com/questions/127f2890-32ce-11eb-9a17-e39cdea6f3f5.png?x-oss-process=image/resize,w_560)



Screen shots of output :

If you find anything wrong please mention it in the
comments. But please do not give thumbs down. It is my humble
request.
HOPE IT SERVED YOUR PURPOSE !!!
PLEASE GIVE THUMBS UP FOR MY ANSWER. I REALLY NEED IT. IT WOULD BE
OF GREAT HELP.
THANK YOU.
I want c++ code for employee payslip calculation using switch statement convert this code to switch...
This C++ program will not let me put numbers in on address, just characters #include using namespace std; float paycalc(){ cout<<"Enter 1 if salary and 2 if hourly: "; int choice, hoursWorked, payrate; float salary; cin>>choice; if(choice == 1){ cout<<"Enter your salary per month: "; cin>>salary; }else{ cout<<"Enter hours worked: "; cin>>hoursWorked; cout<<"Enter pay rate: "; cin>>payrate; salary = hoursWorked * payrate; } return salary; } void printCheck(float sal, int id, char address[30]){ cout<<"Employee id: "<>id; cout<<"Enter address: "; char...
// I am going to use if and else stamtents for this employee pay clalulations. //using if and else to cal salary //If hours worked is <= 40.0 //Employee salry will = hours*pay rate //else //employess salary will =40*pay rate +(hours worked-40)*1.5* pay rate. #include using namespace std; const double Max_Hours= 40.0; const double MuLTIPLER = 1.5; char salary; char payrate; char hours_worked; char Max_hours; char get_total_pay; int main() { double Hours=0; double Payrate = 0; cout <<"Please enter employee...
The switch Statement C++program This lab work with the switch statement. • Remove the break statements from each of the cases. What is the effect on the execution of the program? • Add an additional switch statement that allows for a Passing option for a grade of D or better. Use the sample run given below to model your output. Sample Run: What grade did you earn in Programming I? YOU PASSED! An A - excellent work! The following is...
Code is in C++: Im wondering how i can make the program continue to ask the user to enter Y/N with the if statment. Is it possible with an If statment? #include <iostream> using namespace std; int main() { float usDollars,cYuan; float *Dollars; char choice; Dollars = &usDollars; while(usDollars >= 0){ cout <<"Enter the amount in U.S Dollars: "; cin >> usDollars; cout << usDollars<< " U.S Dollar in Chinese Yuan is :"<<*Dollars*7.09<<endl; if (choice == 'y' || choice ==...
Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout << "Enter an integer cin >> number; if (number > B) cout << You entered a positive integer: " << number << endl; else if (number (8) cout<<"You entered a negative integer: " << number << endl; cout << "You entered e." << endl; cout << "This line is always printed." return 0;
Convert the below code into if else selection: #include <iostream> using namespace std; int main() { int num; sin. >> num; switch (num) { case 1: cout << "Casel: Value is: << num << endl; break; case 2: break; case 3: cout << "Case3: Value is: " << num << endl; break; default: cout << "Default: Value is: << num << endl; break; } return; }
C++ class 3.2.4: If-else statement: Fix errors. Re-type the code and fix any errors. The code should convert non-positive numbers to 1. if (userNum > 0) cout << "Positive." << endl; else cout << "Not positive, converting to 1." << endl; Answer #include using namespace std; int main() { int userNum; cin >> userNum; /* Your solution goes here */ return 0; userNum = 1; cout << "Final: " << userNum << endl;
Hi, I am trying to convert a string vector to a double vector in c++ , but for some reason I am getting this error message. Hope you can help! Thanks error: cannot convert ‘std::string {aka std::basic_string<char>}’ to ‘const char*’ for argument ‘1’ to ‘double atof(const char*)’ double salary = atof(info[x].stringsalary); my code is... void display(vector<Employee_Data>& info){ double total = 0; cout << "id" <<setw(25) <<"first name" <<setw(25) <<"last name" <<setw(25) <<"gender" <<setw(25) <<"department" <<setw(25) <<"salary" << endl ; for(int...
how can we change this c++ code to give the output: Product name: Fluffy Puff Marshmallows Price: $1.99 Fluffy Puff Marshmallows: $1.39 (with 30% discount) correct this code: #include <iostream> #include <string> using namespace std; int main() { string product; float price; cout << "Product name: "; cin >> product; cout << "Price: $"; cin >> price; cout << endl; cout << product << ": $" << price * 0.7 << " (with 30% discount)" << endl; return 0; }
I need to add a for or a while loop to the following code. please help needs to be in c++. #include <iostream> #include <string.h> using namespace std; int main() { char input[100]; cout << "Please enter a character string: "; cin >> input; char *head = &input[0], *tail = &input[strlen(input) - 1]; char temp = *head; *head = *tail; *tail = temp; tail--; head++; cout << "CString = " << input << "\n"; }