Question

For the assignment, we will create a program that will take the annual income and tax...

For the assignment, we will create a program that will take the annual income and tax rate for from 1 to many tax payers, and compute each payer’s amount of taxes that are due for the year. The amount is calculated by taking each payer’s income, multiply it by the tax rate, yielding their taxes ( taxes = income * taxRate ).


Here is the decomposition of tasks:

⦁   Create a structure that contains the tax payer information, the tax rate, the income, and the taxes (all floats).

⦁   Create a vector of these structs, called citizen.

⦁   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 vector 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.

⦁   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 vector 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 following is your driver program. Follow the naming accordingly:
#include <vector>

const int SIZE = 2;

void taxPrint(taxPayer *);
void taxTaker(taxPayer *);

int main()
{
std::vector<taxPayer> citizen;
taxTaker(citizen);
taxPrint(citizen);
return 0;
}

// create your functions

0 0
Add a comment Improve this question Transcribed image text
Answer #1


#include <iostream>
#include <vector>
using namespace std;
struct taxPayer
{
   string name;
   float tax_rate;
   float income;
   float taxes;
};
const int SIZE = 2;

void taxPrint(std::vector<taxPayer> &C);
void taxTaker(std::vector<taxPayer> &C);

int main()
{
std::vector<taxPayer> citizen;
taxTaker(citizen);
taxPrint(citizen);
return 0;
}
void taxTaker(std::vector<taxPayer> &C)
{
taxPayer t;
int count=0;
do
{
   cout<<" Enter Tax Payer name :: ";
   cin>>t.name;
   do
   {  
       cout<<" Enter tax rate (Between 0.01 and 9.9) :: ";
       cin>>t.tax_rate;  
   }while(t.tax_rate<=0.01 || t.tax_rate>9.9);
   do
   {
       cout<<" Enter Income (Greater than 0) :: ";
       cin>>t.income;
   }while(t.income<=0);
   t.taxes=t.income*t.tax_rate;
   C.push_back(t);
   count++;
}while(count!=SIZE);
}
void taxPrint(std::vector<taxPayer> &C)
{
if(C.empty())
cout << " No Tax Payer";
else
{
for (int i = 0; i < C.size(); i++)
{
cout<<" Tax Payer Name :: "<<C[i].name;
cout<<" Tax rate :: "<<C[i].tax_rate;
cout<<" Income :: $"<<C[i].income;
cout<<" Taxes :: $"<<C[i].taxes;
}
}
}

Output

Add a comment
Know the answer?
Add Answer to:
For the assignment, we will create a program that will take the annual income and tax...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I Need Help. I MUST USED VECTOR OF STRUCTUERS INSTEAD OF AN ARRAY. HOW CAN MAKE...

    I Need Help. I MUST USED VECTOR OF STRUCTUERS INSTEAD OF AN ARRAY. HOW CAN MAKE THIS INTO VECTOR STRUCTUERS? #include #include using namespace std; // This program demonstrates how to use an array of structures// PLACE YOUR NAME HERE // Fill in code to define a structure called taxPayer that has three// members: taxRate, income, and taxes -- each of type float int main(){   // Fill in code to declare an array named citizen which holds   // 5 taxPayers structures cout...

  • Part 1 Fill in the code below as indicated by the comments in bold // PLACE...

    Part 1 Fill in the code below as indicated by the comments in bold // PLACE YOUR NAME HERE // This program demonstrates how to use an array of structures #include <iostream> #include <iomanip> using namespace std; // Fill in code to declare a structure called taxpayer that has three // members: taxRate, income, and taxes – each of type float // ??? int main() { // Fill in code to define an array named citizen which holds 1/ 5...

  • The program calculates a tax rate and tax to pay given an annual salary. The program...

    The program calculates a tax rate and tax to pay given an annual salary. The program uses a class, TaxTableTools, which has the tax table built in. Run the program with annual salaries of 10000, 50000, 50001, 100001 and -1 (to end the program) and note the output tax rate and tax to pay. The output should be as follows: Enter annual salary (-1 to exit): 10000 Annual Salary: 10000 Tax rate: 0.1 Tax to pay: 1000 Enter annual salary...

  • Create a new program in Mu and save it as ps3.4.1.py and take the code below...

    Create a new program in Mu and save it as ps3.4.1.py and take the code below and fix it as indicated in the comments: # Write a function called hide_and_seek. The function should # have no parameters and return no value; instead, when # called, it should just print the numbers from 1 through 10, # follow by the text "Ready or not, here I come!". Each # number and the message at the end should be on its own...

  • Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that...

    Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions. • void getScore() should ask the user for a test score, store it in the reference parameter variable, and validate it. This function should be called by the main once for each of the five scores to be entered. •...

  • Write a C++ program that will count the number of words and vowels in a sentence....

    Write a C++ program that will count the number of words and vowels in a sentence. Create a bool function called isVowel that accepts a character as a parameter and returns a true if it’s a vowel (aeiou) and false otherwise. Create an int function named countVowels that will accept a string variable as a parameter and will return the number of vowels in it. Call the isVowel function as part of this process. Write an int function named countWords...

  • COSC 1437 C++ Project Assignment 2 Poll Summary Utilize a dynamic array of structure to summarize...

    COSC 1437 C++ Project Assignment 2 Poll Summary Utilize a dynamic array of structure to summarize votes for a local election Specification: Write a program that keeps track the votes that each candidate received in a local election. The program should output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. To solve this problem, you will use one dynamic...

  • Can someone help me with this? Create a mini program including a main() method and void...

    Can someone help me with this? Create a mini program including a main() method and void methods where arrays are nxn i.e. same no. of rows & columns 1. displayArray(): Takes one parameter, a 2D symmetrical int array called "symmetric" & print the array as shown in the sample output. 2. shiftTheRowsBelow(): Takes one parameter, a 2D symmetrical int array called "symmetric". It will take the given values in the last row of the array, move them to the first...

  • Create a new program in Mu and save it as ps4.4.1.py and take the code below...

    Create a new program in Mu and save it as ps4.4.1.py and take the code below and fix it as indicated in the comments: # Write a function called "save_leaderboard" that accepts a # single list of tuples as a parameter. The tuples are of the # form (leader_name, score) # The function should open a file called "leaderboard.txt", # and write each of the tuples in the list to a line in the file. # The name and score...

  • in c++ please Assignment Instructions: MAIN FUNCTION: Ask the user how many students were surveyed.   Call...

    in c++ please Assignment Instructions: MAIN FUNCTION: Ask the user how many students were surveyed.   Call a function called makeArray to define an array of integers with the number of elements equal to the number of students surveyed. Call a function called getStudentData to allow the user to enter the number of hours each student spent watching Netflix into the array. Call a function called getAverage to calculate and display the average of the hours entered. Call a function called...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT