Tuesday, 25 August 2015

Write a program that can be used to calculate the federal tax. The tax is calculated as follows: For single people, the standard exemption is RS4,000; for married people, the standard exemption is RS7,000. A person can also put up to 6% of his or her gross income in a pension plan. The tax rates are as follows: If the taxable income is:  Between RS0 and RS15,000, the tax rate is 15%.  Between RS15,001 and RS40,000, the tax is RS2,250 plus 25% of the taxable income over RS15,000.  Over RS40,000, the tax is RS8,460 plus 35% of the taxable income over RS40,000

#include "stdafx.h"
#include <iostream>
using namespace std;

void taxOfMaried();
void single();

int main()
{
char status;
int choice;
do
{
cout << "Enter your Martial Status ('m' for married 's' for single): ";
cin >> status;
if (status == 'm' || status == 'M')
taxOfMaried();
else if (status == 's' || status == 'S')
single();
else
cout << "Invalid Input." << endl;

cout << "\n Enter 1 to re-run: ";
cin >> choice;
} while (choice == 1);

system("pause");
return 0;
}

void taxOfMaried()
{
int exemption = 7000;
int salary, wifesalary, numchild, totalsalary, tempsalary;
float tax, pention;

cout << "Ener the salary of your wife: ";
cin >> wifesalary;
cout << "Enter your salary: ";
cin >> salary;
cout << "Enter the number of child of age under age 14: ";
cin >> numchild;

totalsalary = salary + wifesalary;

if (numchild == 2)
exemption = exemption * 4;

cout << "Your Exemption is: " << exemption << endl;
tempsalary = totalsalary;
tempsalary = tempsalary - exemption;

if (tempsalary <= 15000)
tax = tempsalary * (15.0 / 100.0);
else if (tempsalary <= 40000)
tax = 2250 + (tempsalary * (25.0 / 100.0));
else
tax = 8460 + (tempsalary * (35.0 / 100.0));

pention = totalsalary * (6.0 / 100.0);
tax = tax + pention;

cout << "Your total tax on salary (including pention):" << totalsalary << endl;
cout << "Your remaining salary is: " << tempsalary - tax - exemption << endl;
}

void single()
{
int exemption = 4000;
float tax, pention;
int salary, tempsalary;
cout << "Enter your salary: ";
cin >> salary;
tempsalary = salary;
tempsalary = tempsalary - exemption;

if (tempsalary <= 15000)
tax = tempsalary * (15.0 / 100.0);
else if (tempsalary <= 40000)
tax = 2250 + tempsalary * (25.0 / 100.0);
else
tax = 8460 + tempsalary * (35.0 / 100.0);

cout << "Your exemption is: " << exemption << endl;

pention = salary * (6.0 / 100.0);
cout << "Your tax without pention fund is: " << tax << endl;
cout << "Your salary after including pention: " << tax + pention << endl;
cout << "Your salary after paying tax: " << salary - exemption - tax - pention << endl;
}

No comments:

Post a Comment