Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
In this assignment you will demonstrate the use of a combination of selection and loop
structure in C++ programming.
Part A:
For this assignment you are required to create a program for Mastiff Hotel Group of Companies
to assist them in automating the Income Tax Calculation process for all its employees. The
employee tax deduction varies based on their age and annual income. The Tax calculation
table below has the details:
Age < 55
0% tax if annual income < 10 000,
10% tax if 10 000 ≤ annual income ≤ 50 000
20% tax if 50 000 < annual income ≤ 100 000
30% tax if annual income > 100 000
55 ≤ Age < 80
0% tax if annual income < 20 000,
10% tax if 20 000 ≤ annual income ≤ 70 000
20% tax if 70 000 < annual income ≤ 150 000
30% tax if annual income > 150 000
Age ≥ 80 and Age ≤ 120
0% tax if annual income (No Tax)
 Exception-handling – the program should allow only legitimate Age and Annual
Income.
Tax Calculation Program
The program should request for the employee names, FNPF#, Age and Annual Income. Using
the information entered, the program must generate the Income Tax slip for the employee.
Once that information has been captured, the program must then ask the user if they need
to generate an income tax slips for another employee. The program must allow the user to
continue generating tax calculation slips until the user enters ‘N’ for NO, which marks the end
of the session.
A sample User Prompt screen is provided below:
Enter Employee Names: Michael Buadromo
Enter Employee FNPF#: 100200
Enter Employee Age: 38
Enter Employee Annual Income: 40000
CSC511 Introduction to C++ Page 2 of 3
A sample taxslip for employee Michael Buadromo is provided below:
***********************************************************
Mastiff Hotel Group of Companies
 ***********************************************************
Employee Name: Michael Buadromo
FNPF: 100200
Summary:
--------
Annual Income: $ 40000.00
Age: 38
Income Tax Rate: 10%
Income Tax Amount $ 4000.00
************************************************************
Note that the first column is left-justified, and the right column is
right justified.


What I have tried:

#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;

int main()
{
	//declare varible
	char name;
	int FNPF, age, annualIncome, income_tax_amount;
	float income_tax_rate;
	
	// input
	
	cout<< "Enter Employee Names: " <<endl;
	cin>> name;
	
	cout<< "Enter Employee FNPF#: " <<endl;
	cin>> FNPF;
	
	cout<< "Enter Employee Age: " <<endl;
	cin>> age;
	
	cout<< "Enter Employee Annual Income: " <<endl;
	cin>> annualIncome;
	
	cout<<"\n\n";
	
	//decimal points
	
	cout;
	fixed;
	setprecision(2);
	
	{
   double tax=0.0;
   if(age<55)
   {
       if(annualIncome<10000)
       {
           tax=0.0;
       }
       else if(annualIncome>=10000 && annualIncome<=50000)
       {
           tax=annualIncome*0.10;
       }
       else if(annualIncome>50000 && annualIncome<=100000)
       {
           tax=annualIncome*0.20;
       }
       else if(annualIncome>100000)
       {
           tax=annualIncome*0.30;
       }  
   }
   else if(age>=55 && age<80)
   {
      if(annualIncome<20000)
       {
           tax=0.0;
       }
       else if(annualIncome>=20000 && annualIncome<=70000)
       {
           tax=annualIncome*0.10;
       }
       else if(annualIncome>70000 && annualIncome<=150000)
       {
           tax=annualIncome*0.20;
       }
       else if(annualIncome>150000)
       {
           tax=annualIncome*0.30;
       }      
   }
   else if(age>=80)
   {
       tax=0.0;
   }
  
   return tax;
}
	
	
}



[edit]
i want my output to be like this:

Enter Employee Names: Michael Buadromo
Enter Employee FNPF#: 100200
Enter Employee Age: 38
Enter Employee Annual Income: 40000

***********************************************************
Mastiff Hotel Group of Companies
 ***********************************************************
Employee Name: Michael Buadromo
FNPF: 100200
Summary:
--------
Annual Income: $ 40000.00
Age: 38
Income Tax Rate: 10%
Income Tax Amount $ 4000.00
************************************************************


i used this code:
C++
#include <iomanip>
#include <iostream>
using namespace std;


int main()
{
	string name;
	int FNPF;
	int age;
	int tax;
	float annualIncome;
	float income_tax_rate;
	float income_tax_amount;
    
   
	cout << "Enter Employee Name: " << endl; 
	cin >> (name);
	
	cout << " Enter Employee FNPF#" <<endl;
 cin="">> FNPF;
	
	cout << "Enter Employee Age" <<endl;
 cin="">> age;
	
	cout << "Enter Employee Annual Income:" <<endl;
 cin="">>annualIncome;
    


    //decimal points
	
	cout;
	fixed;
	setprecision(2);
	
		
   tax=0.0;
   if(age<55)
   {
       if(annualIncome<10000)
       {
           tax=0.0;
       }
       else if(annualIncome>=10000 && annualIncome<=50000)
       {
           tax=annualIncome*0.10;
       }
       else if(annualIncome>50000 && annualIncome<=100000)
       {
           tax=annualIncome*0.20;
       }
       else if(annualIncome>100000)
       {
           tax=annualIncome*0.30;
       }  
   }
   else if(age>=55 && age<80)
   {
      if(annualIncome<20000)
       {
           tax=0.0;
       }
       else if(annualIncome>=20000 && annualIncome<=70000)
       {
           tax=annualIncome*0.10;
       }
       else if(annualIncome>70000 && annualIncome<=150000)
       {
           tax=annualIncome*0.20;
       }
       else if(annualIncome>150000)
       {
           tax=annualIncome*0.30;
       }      
   }
   else if(age>=80)
   {
       tax=0.0;
   }
       
cout << "\t****************************************************************"<< endl;
cout <<"\t\ Mastiff Hotel Group Of Companies"<< endl;
cout << "\t****************************************************************" << endl;	
cout << "\tEmployee Name:\t\t\t\t"<


[/edit]
Posted
Updated 9-May-21 0:41am
v2
Comments
Luisa Vusoniceva 9-Jun-21 17:37pm    
I need help with using percentage in my coding in terms of doing income tax rate because when I'm trynna do it the Number 0 keeps coming in front when ever I use printf(10%%).

Nope. That's not how it works around here. This isn't a "do my work for me" site.

If you've got a specific question or problem with your code, great, ask away.
 
Share this answer
 
Comments
innocent jholz 9-May-21 6:27am    
i want my output to be like this:

Enter Employee Names: Michael Buadromo
Enter Employee FNPF#: 100200
Enter Employee Age: 38
Enter Employee Annual Income: 40000

***********************************************************
Mastiff Hotel Group of Companies
***********************************************************
Employee Name: Michael Buadromo
FNPF: 100200
Summary:
--------
Annual Income: $ 40000.00
Age: 38
Income Tax Rate: 10%
Income Tax Amount $ 4000.00
************************************************************

i used this code:
#include <iomanip>
#include <iostream>
using namespace std;


int main()
{
string name;
int FNPF;
int age;
int tax;
float annualIncome;
float income_tax_rate;
float income_tax_amount;


cout << "Enter Employee Name: " << endl;
cin >> (name);

cout << " Enter Employee FNPF#" <<endl;
cin="">> FNPF;

cout << "Enter Employee Age" <<endl;
cin="">> age;

cout << "Enter Employee Annual Income:" <<endl;
cin="">>annualIncome;



//decimal points

cout;
fixed;
setprecision(2);


tax=0.0;
if(age<55)
{
if(annualIncome<10000)
{
tax=0.0;
}
else if(annualIncome>=10000 && annualIncome<=50000)
{
tax=annualIncome*0.10;
}
else if(annualIncome>50000 && annualIncome<=100000)
{
tax=annualIncome*0.20;
}
else if(annualIncome>100000)
{
tax=annualIncome*0.30;
}
}
else if(age>=55 && age<80)
{
if(annualIncome<20000)
{
tax=0.0;
}
else if(annualIncome>=20000 && annualIncome<=70000)
{
tax=annualIncome*0.10;
}
else if(annualIncome>70000 && annualIncome<=150000)
{
tax=annualIncome*0.20;
}
else if(annualIncome>150000)
{
tax=annualIncome*0.30;
}
}
else if(age>=80)
{
tax=0.0;
}

cout << "\t****************************************************************"<< endl;
cout <<"\t\ Mastiff Hotel Group Of Companies"<< endl;
cout << "\t****************************************************************" << endl;
cout << "\tEmployee Name:\t\t\t\t"<
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 
Comments
innocent jholz 9-May-21 0:11am    
this how the out should look like.....i have also posted what i tried...but cant gent the same output.....please can you help me to solve this
Enter Employee Names: Michael Buadromo
Enter Employee FNPF#: 100200
Enter Employee Age: 38
Enter Employee Annual Income: 40000

***********************************************************
Mastiff Hotel Group of Companies
***********************************************************
Employee Name: Michael Buadromo
FNPF: 100200
Summary:
--------
Annual Income: $ 40000.00
Age: 38
Income Tax Rate: 10%
Income Tax Amount $ 4000.00
************************************************************
C++
       if(annualIncome<10000)
       {
           tax=0.0;
       }
// if the code reaches this point then the value must be >= 10000, so that clause is redundant
//       else if(annualIncome>=10000 && annualIncome<=50000)
       else if(annualIncome <= 50000) // just test for the next limit
       {
           tax=annualIncome*0.10;
       }
 
Share this answer
 
Comments
innocent jholz 9-May-21 0:13am    
please help what is missing in my code
this how the output looks

Enter Employee Names: Michael Buadromo
Enter Employee FNPF#: 100200
Enter Employee Age: 38
Enter Employee Annual Income: 40000

***********************************************************
Mastiff Hotel Group of Companies
***********************************************************
Employee Name: Michael Buadromo
FNPF: 100200
Summary:
--------
Annual Income: $ 40000.00
Age: 38
Income Tax Rate: 10%
Income Tax Amount $ 4000.00
************************************************************
Richard MacCutchan 9-May-21 3:17am    
No idea. What is wrong with that output?
innocent jholz 9-May-21 6:24am    
i want my output to be like this:

Enter Employee Names: Michael Buadromo
Enter Employee FNPF#: 100200
Enter Employee Age: 38
Enter Employee Annual Income: 40000

***********************************************************
Mastiff Hotel Group of Companies
***********************************************************
Employee Name: Michael Buadromo
FNPF: 100200
Summary:
--------
Annual Income: $ 40000.00
Age: 38
Income Tax Rate: 10%
Income Tax Amount $ 4000.00
************************************************************

i used this code:
#include <iomanip>
#include <iostream>
using namespace std;


int main()
{
string name;
int FNPF;
int age;
int tax;
float annualIncome;
float income_tax_rate;
float income_tax_amount;


cout << "Enter Employee Name: " << endl;
cin >> (name);

cout << " Enter Employee FNPF#" <<endl;
cin="">> FNPF;

cout << "Enter Employee Age" <<endl;
cin="">> age;

cout << "Enter Employee Annual Income:" <<endl;
cin="">>annualIncome;



//decimal points

cout;
fixed;
setprecision(2);


tax=0.0;
if(age<55)
{
if(annualIncome<10000)
{
tax=0.0;
}
else if(annualIncome>=10000 && annualIncome<=50000)
{
tax=annualIncome*0.10;
}
else if(annualIncome>50000 && annualIncome<=100000)
{
tax=annualIncome*0.20;
}
else if(annualIncome>100000)
{
tax=annualIncome*0.30;
}
}
else if(age>=55 && age<80)
{
if(annualIncome<20000)
{
tax=0.0;
}
else if(annualIncome>=20000 && annualIncome<=70000)
{
tax=annualIncome*0.10;
}
else if(annualIncome>70000 && annualIncome<=150000)
{
tax=annualIncome*0.20;
}
else if(annualIncome>150000)
{
tax=annualIncome*0.30;
}
}
else if(age>=80)
{
tax=0.0;
}

cout << "\t****************************************************************"<< endl;
cout <<"\t\ Mastiff Hotel Group Of Companies"<< endl;
cout << "\t****************************************************************" << endl;
cout << "\tEmployee Name:\t\t\t\t"<
Richard MacCutchan 9-May-21 6:44am    
You just need to add the extra cout statements to print the employee details.
innocent jholz 9-May-21 21:39pm    
and what is the formula
and how to write formula using loop and selection

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900