#include <iostream>
using namespace std;
struct employee{
int emp_Id;
char empName[11];
char empdeptName[15];
double monthly_salary;
double yearly_sal, yearly_Tax, monthly_Tax;
void setSalary()
{
cout << "Enter your monthly salary : ";
cin >> monthly_salary;
getSalary();
/*
if(monthly_salary > 0 && monthly_salary < 80000)
{
getSalary();
}
else
{
exit();
}*/
}
void getSalary()
{
system("cls");
cout << "Your monthly salary is : " << monthly_salary << endl;
yearly_sal = monthly_salary * 12;
cout << "Your annual salary is : " << yearly_sal << endl;
yearly_Tax = yearly_sal * 7 / 100;
cout << "Your annual tax at the rate of 7 % is : " << yearly_Tax << endl;
cout << "Your monthly tax is : " << compute_Monthly_Tax() << endl;
}
void showSalaryOriginal()
{
cout << "Your monthly salary is : " << monthly_salary << endl;
cout << "Your annual salary is : " << yearly_sal<< endl;
}
void ShowSalaryAfterTax()
{
cout << "Your monthly salary after tax is : " << monthly_salary - monthly_Tax << endl;
cout << "Your annual salary after tax is : " << yearly_sal - yearly_Tax << endl;
}
double compute_Monthly_Tax()//Function will compute monthly tax
{
monthly_Tax = yearly_Tax / 12;
return monthly_Tax;
}
void exit()
{
cout << "End!!";
}
};
int main()
{
//Declaring variable of employee struct
employee emp;
cout << "Enter employee name : ";
cin.getline(emp.empName, 11);
cout << "Enter employee id : ";
cin >> emp.emp_Id;
emp.setSalary();
emp.showSalaryOriginal();
emp.ShowSalaryAfterTax();
system("pause");
return 0;
}
using namespace std;
struct employee{
int emp_Id;
char empName[11];
char empdeptName[15];
double monthly_salary;
double yearly_sal, yearly_Tax, monthly_Tax;
void setSalary()
{
cout << "Enter your monthly salary : ";
cin >> monthly_salary;
getSalary();
/*
if(monthly_salary > 0 && monthly_salary < 80000)
{
getSalary();
}
else
{
exit();
}*/
}
void getSalary()
{
system("cls");
cout << "Your monthly salary is : " << monthly_salary << endl;
yearly_sal = monthly_salary * 12;
cout << "Your annual salary is : " << yearly_sal << endl;
yearly_Tax = yearly_sal * 7 / 100;
cout << "Your annual tax at the rate of 7 % is : " << yearly_Tax << endl;
cout << "Your monthly tax is : " << compute_Monthly_Tax() << endl;
}
void showSalaryOriginal()
{
cout << "Your monthly salary is : " << monthly_salary << endl;
cout << "Your annual salary is : " << yearly_sal<< endl;
}
void ShowSalaryAfterTax()
{
cout << "Your monthly salary after tax is : " << monthly_salary - monthly_Tax << endl;
cout << "Your annual salary after tax is : " << yearly_sal - yearly_Tax << endl;
}
double compute_Monthly_Tax()//Function will compute monthly tax
{
monthly_Tax = yearly_Tax / 12;
return monthly_Tax;
}
void exit()
{
cout << "End!!";
}
};
int main()
{
//Declaring variable of employee struct
employee emp;
cout << "Enter employee name : ";
cin.getline(emp.empName, 11);
cout << "Enter employee id : ";
cin >> emp.emp_Id;
emp.setSalary();
emp.showSalaryOriginal();
emp.ShowSalaryAfterTax();
system("pause");
return 0;
}
No comments:
Post a Comment