Please help Array of Structs c 1 Create a structure that con

Please help Array of Structs (c++)

1. Create a structure that contains the tax payer information, the tax rate, the income, and the taxes (all floats). This should be in an implementation file called taxPayer

2. Create an unnamed namespace that contains the constant size, for the size of the array

3. Create an array of these structs, called citizen.

4. Create a function called taxTaker that will accept the structure as a parameter. This function will take user information for each payer, up to the size of the array of structures. The function should take the inputs for the income and the tax rate elements, and then store the computation in the taxes element. This function should also use standard input validation and ensure the data is good (numeric), and that it falls with the range of 0.01 through 9.9 for rate, and income amounts are greater than zero.

5. Create a function called taxPrint that will accept the structure as a parameter input and print out the total taxes due for all the payers in the array to standard output. Make sure to format the output in accord with the sample output below. The output should be for dollar amounts. This will print for each payer, up to the size.

the output should look like this

C: CodeBlocks arrayofstructs Abin Debug WarrayotStructs exe Please enter the annual income and tax rate for 2 tax payers Enter this year\'s income for tax payer 1 60000 Enter the tax rate for tax payer 1: 7.5 Enter this year\'s income for tax payer 2 50000 Enter the tax rate for tax payer 2: 4.2 Taxes due for this year: Tax Payer 1 4500.00 Payer 2: 2100.00

Solution

#include <iostream>

#include <iomanip>

using namespace std;

// This program demonstrates how to use an array of structures

// Cuong Pham

// Fill in code to define a structure called taxPayer that has three

// members: taxRate, income, and taxes -- each of type float

struct taxPayer {

    float taxRate, income, taxes;

};

int main()

{

   // Fill in code to declare an array named citizen which holds

   // 5 taxPayers structures

  

   taxPayer citizen[5];

                cout << fixed << showpoint << setprecision(2);

                cout << \"Please enter the annual income and tax rate for 5 tax payers: \";

                cout << endl << endl << endl;

                for(int count = 0;count < 5;count++)

                {

                                cout << \"Enter this year\'s income for tax payer \" << (count + 1);

                                cout << \": \";

                               

                                cin >> citizen[count].income;

                                // Fill in code to read in the income to the appropriate place

                                cout << \"Enter the tax rate for tax payer # \" << (count + 1);

                                cout << \": \";

                               

                                cin >> citizen[count].taxRate;

                                // Fill in code to read in the tax rate to the appropriate place

                                // Fill in code to compute the taxes for the citizen and store it

                                // in the appropriate place

        citizen[count].taxes = citizen[count].income * citizen[count].taxRate;

               

                                cout << endl;

                }

                cout << \"Taxes due for this year: \" << endl << endl;

                // Fill in code for the first line of a loop that will output the

                // tax information

                for (int index = 1; index < 5; index++)

                {

                                cout << \"Tax Payer # \" << (index + 1) << \": \" << \"$ \"

                                                << citizen[index].taxes << endl;

                }

                return 0;

}

Please help Array of Structs (c++) 1. Create a structure that contains the tax payer information, the tax rate, the income, and the taxes (all floats). This sho
Please help Array of Structs (c++) 1. Create a structure that contains the tax payer information, the tax rate, the income, and the taxes (all floats). This sho

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site