can you please help me with this Q .. i need you give me a simple code with C++
ID: 3752068 • Letter: C
Question
can you please help me with this Q .. i need you give me a simple code with C++ ISO , and answer A, B, C .. YOU CAN FIND there answer online but its really compex ..
4. Define a class named TaxReturn that contains a tax ID number, last name, first name, annual income, number of dependents, and amount of tax owed for a taxpayer Include constant static fields that hold the tax rates for the situations shown in the following table Income (S) 0-10,000 0,001-30,000 0,001-60,000 60,001 and up 0 dependents 0.10 0.12 0.18 0.25 1 dependent 0.08 0.11 0.15 0.22 2 or more dependents 0.07 0.09 0.13 0.19 Include a static function that displays the tax table. Write a main) function that contains a single statement that displays the tax table Add two public functions to the TaxReturn class: setAllO, which can set the field values and display), which can display them. The setAllOfunction accepts arguments for the tax ID number, last and first names, annual income, and number of dependents The setAllOfunction should then call a private function that computes the tax owed. Create an array of 10 TaxReturnobiects. In a loop, prompt the user for ID number, first and last name, annual income, and number of dependents, then use these values to set a TaxReturn's fields. At the end of the loop, display all the values for all 10 TaxReturn objects, including the tax owed a) Draw a flowchart illustrating the program design to solve this problem. (4 Marks) b) Write visual basic program, execute the program with sample inputs and show the outputs. (5 Marks) c) Attach the screen shots of the program, inputs and output. (1 Mark)Explanation / Answer
ScreenShot
---------------------------------------------------
Program
//Header files for I/O,string and manipulation
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
//Constant variables
const double taxRate01 = 0.10, taxRate02 = 0.12, taxRate03 = 0.18, taxRate04 = 0.25, taxRate11 = 0.08, taxRate12 = 0.11, taxRate13 = 0.15, taxRate14 = 0.22, taxRate21 = 0.07, taxRate22 = 0.09, taxRate23 = 0.13, taxRate24 = 0.19;
//Function prototype
void displayTaxTable();
//Create a class
class TaxReturn {
//Member variables
private:
string taxId;
string lastname;
string firstname;
int depenednts;
double annualIncome;
double tax;
//Private function to calculate income
double taxOwed(int dep, double income) {
if (annualIncome >= 0 && annualIncome <= 10000) {
if (dep == 0) {
return annualIncome * taxRate01;
}
else if (dep == 1) {
return annualIncome * taxRate11;
}
else if (dep >= 2) {
return annualIncome * taxRate21;
}
}
else if (annualIncome >= 10001 && annualIncome <= 30000) {
if (dep == 0) {
return annualIncome * taxRate02;
}
else if (dep == 1) {
return annualIncome * taxRate12;
}
else if (dep >= 2) {
return annualIncome * taxRate22;
}
}
else if (annualIncome >= 30001 && annualIncome <= 60000) {
if (dep == 0) {
return annualIncome * taxRate03;
}
else if (dep == 1) {
return annualIncome * taxRate13;
}
else if (dep >= 2) {
return annualIncome * taxRate23;
}
}
else if (annualIncome >= 60001) {
if (dep == 0) {
return annualIncome * taxRate04;
}
else if (dep == 1) {
return annualIncome * taxRate14;
}
else if (dep >= 2) {
return annualIncome * taxRate24;
}
}
}
//Member methods
public:
//Default constructor
TaxReturn() {
taxId = "";
lastname = "";
firstname = "";
depenednts = 0;
annualIncome = 0.0;
tax = 0.0;
}
//Set all variables value
void setAll(string id, string lname, string fname, int dep,double income) {
taxId = id;
lastname =lname;
firstname = fname;
depenednts = dep;
annualIncome = income;
//Call private method to set tax
tax = taxOwed(depenednts, annualIncome);
}
//Display all details
void display() {
cout << fixed << setprecision(2);
cout << "TaxId= " << taxId << " TaxPayerName= " << firstname << " " << lastname << " AnnualIncome= $" << annualIncome << " NumberOfDependents= " << depenednts << " TaxOwed= $" << tax << endl;
}
};
//Main method
int main()
{
//Variables for input
string fname, lname, id;
double income;
int dependants;
//Call function to display tax detail table
displayTaxTable();
cout << endl;
//Create a class array
TaxReturn tr[10];
//Loop through to get values
for (int i = 0; i < 10; i++) {
cout << "Enter the name of the payer(firstname lastname): ";
cin >> fname >> lname;
cout << "Enter Tax ID: ";
cin >> id;
cout << "Enter annual income($): ";
cin >> income;
cout << "Enter number of dependents: ";
cin >> dependants;
//Set values
tr[i].setAll(id, lname, fname, dependants, income);
}
//Loop through to display
for (int i = 0; i < 10; i++) {
tr[i].display();
}
return 0;
}
//Tax detail table display method
void displayTaxTable() {
cout << " Tax Range Table " << endl;
cout << "Income($) 0 dependent 1 dependent 2 or more dependent ----------------------------------------------------------------------" << endl;
cout << fixed << setprecision(2);
cout << "0-10,000 " << taxRate01 << " " << taxRate11 << " " << taxRate21 << endl;
cout << "10,001-30,000 " << taxRate02 << " " << taxRate12 << " " << taxRate22 << endl;
cout << "30,001-60,000 " << taxRate03 << " " << taxRate13 << " " << taxRate23 << endl;
cout << "60,001 and Up " << taxRate04 << " " << taxRate14 << " " << taxRate24 << endl;
}
--------------------------------------------------------
Output
Tax Range Table
Income($) 0 dependent 1 dependent 2 or more dependent
----------------------------------------------------------------------
0-10,000 0.10 0.08 0.07
10,001-30,000 0.12 0.11 0.09
30,001-60,000 0.18 0.15 0.13
60,001 and Up 0.25 0.22 0.19
Enter the name of the payer(firstname lastname): David John
Enter Tax ID: 1234
Enter annual income($): 10000
Enter number of dependents: 0
Enter the name of the payer(firstname lastname): Mary Maron
Enter Tax ID: 4521
Enter annual income($): 20000
Enter number of dependents: 1
Enter the name of the payer(firstname lastname): Maya Davon
Enter Tax ID: 4785
Enter annual income($): 30000
Enter number of dependents: 2
Enter the name of the payer(firstname lastname): Moorthy la
Enter Tax ID: 4523
Enter annual income($): 40000
Enter number of dependents: 0
Enter the name of the payer(firstname lastname): Kiran hoda
Enter Tax ID: 4500
Enter annual income($): 22
Enter number of dependents: 0
Enter the name of the payer(firstname lastname): Klay Main
Enter Tax ID: 4785
Enter annual income($): 45000
Enter number of dependents: 3
Enter the name of the payer(firstname lastname): Taylor gatt
Enter Tax ID: 4265
Enter annual income($): 25000
Enter number of dependents: 1
Enter the name of the payer(firstname lastname): Raven hope
Enter Tax ID: 9832
Enter annual income($): 51000
Enter number of dependents: 2
Enter the name of the payer(firstname lastname): Riya Batt
Enter Tax ID: 4163
Enter annual income($): 48000
Enter number of dependents: 0
Enter the name of the payer(firstname lastname): Ron Maze
Enter Tax ID: 5289
Enter annual income($): 52000
Enter number of dependents: 2
TaxId= 1234 TaxPayerName= David John AnnualIncome= $10000.00 NumberOfDependents= 0 TaxOwed= $1000.00
TaxId= 4521 TaxPayerName= Mary Maron AnnualIncome= $20000.00 NumberOfDependents= 1 TaxOwed= $2200.00
TaxId= 4785 TaxPayerName= Maya Davon AnnualIncome= $30000.00 NumberOfDependents= 2 TaxOwed= $2700.00
TaxId= 4523 TaxPayerName= Moorthy la AnnualIncome= $40000.00 NumberOfDependents= 0 TaxOwed= $7200.00
TaxId= 4500 TaxPayerName= Kiran hoda AnnualIncome= $22.00 NumberOfDependents= 0 TaxOwed= $2.20
TaxId= 4785 TaxPayerName= Klay Main AnnualIncome= $45000.00 NumberOfDependents= 3 TaxOwed= $5850.00
TaxId= 4265 TaxPayerName= Taylor gatt AnnualIncome= $25000.00 NumberOfDependents= 1 TaxOwed= $2750.00
TaxId= 9832 TaxPayerName= Raven hope AnnualIncome= $51000.00 NumberOfDependents= 2 TaxOwed= $6630.00
TaxId= 4163 TaxPayerName= Riya Batt AnnualIncome= $48000.00 NumberOfDependents= 0 TaxOwed= $8640.00
TaxId= 5289 TaxPayerName= Ron Maze AnnualIncome= $52000.00 NumberOfDependents= 2 TaxOwed= $6760.00
Press any key to continue . . .
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.