Answer to Question #47368 in C++ for joney

Question #47368
Write a complete program that computes and print the final salary of an employee.
First of all the program should ask the employee to enter his basic salary (please enter your basic salary)
The user then should be asked if he married or not . ( are you married? )
If the user is married, you should ask him if he has kids or not. ( do you have kids?)
If the user has kids you should ask him how many kids he/she has. ( how many kids do you have?)
If the user basic salary is lower than 200 JD the tax percentage is 0.01 on his basic salary
If the user basic salary is between 200 and 500 JD the tax percentage is 0.02 on his basic salary
If the basic salary is more than 500 JD the tax percentage is 0.03 on his basic salary

NOTE:
If the user is single he will not get any bonus to his salary
If the user is married he will get 50 JD bonus on his salary
If the user has kids he will have 20 JD bonus for each child he/she has
1
Expert's answer
2014-10-06T02:19:59-0400
#include <iostream>
using namespace std;
int main() {
float salary;
int kid_cnt;
bool married = false, kids = false;
cout << "Please enter your basic salary: ";
cin >> salary;

cout << "Are you married?(y/n) ";
char ch;
cin >> ch;
if (ch == 'y') {
married = true;
cout << "Do you have kids?(y/n) ";
cin >> ch;
if (ch == 'y') {
kids = true;
cout << "How many kids do you have? ";
cin >> kid_cnt;
}
}
if (salary < 200) salary -= 0.01 * salary;
else if (salary <= 500) salary -= 0.02 * salary;
else salary -= 0.03 * salary;
if (married) salary += 50;
if (kids) salary += kid_cnt * 20;
cout << "Final salary is " << salary << endl;
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS