write a c++ program using switch statement that assigns to thevariable rank the
ID: 3615800 • Letter: W
Question
write a c++ program using switch statement that assigns to thevariable rank the expected salary of an employee whose rank hasbeen stored in rank, rank A pays 9% tax, rank B pays 7% tax, rank Cpays 6% tax, and rank D pays 5% tax. Let your program accept therank of employee from user, and then calculate the Tax deductionand Net salary after tax deductions. Use the following table. Netsalary= salary -Tax . Rank A B C D Salary 25000 20000 15000 10000 sample output: Enter Rank:B Tax deduction is 1400 the net salary is 18600 write a c++ program using switch statement that assigns to thevariable rank the expected salary of an employee whose rank hasbeen stored in rank, rank A pays 9% tax, rank B pays 7% tax, rank Cpays 6% tax, and rank D pays 5% tax. Let your program accept therank of employee from user, and then calculate the Tax deductionand Net salary after tax deductions. Use the following table. Netsalary= salary -Tax . Rank A B C D Salary 25000 20000 15000 10000 sample output: Enter Rank:B Tax deduction is 1400 the net salary is 18600 Rank A B C D Salary 25000 20000 15000 10000Explanation / Answer
#include <iostream.h> #include <conio.h>int main() {
char rank; int bsal, gsal; float tax=0;
cout<<"Enter Rank:"; cin>>rank;
switch(rank) { case 'a': case 'A': bsal=25000; tax=bsal*0.09; break;
case 'b': case 'B': bsal=2000; tax=bsal*0.07; break;
case 'c': case 'C': bsal=15000; tax=bsal*0.06; break;
case 'd': case 'D': bsal=10000; tax=bsal*0.05; break;
}
cout<<"Tax Deduction:"<<tax; cout<<" NetSalary:"<<(bsal-tax);
getch(); return 0; }
Please Rate
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.