Question

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 << 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 << ": ";// Fill in code to read in the income to the appropriate placecout << "Enter the tax rate for tax payer # " << (count + 1);
cout << ": ";// 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

  

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{cout << "Tax Payer # " << (index + 1) << ": " << "$ "

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

}return 0;

}

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

#include <iostream>

#include <iomanip>

#include <vector>

using namespace std;

struct taxPayer {

float taxRate;

float income;

float taxes;

};

int main() {

vector<taxPayer> citizen;

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++) {

taxPayer m_taxPayer;

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

cin >> m_taxPayer.income;

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

cin >> m_taxPayer.taxRate;

m_taxPayer.taxes = (m_taxPayer.income * m_taxPayer.taxRate) / 100;

  

citizen.push_back (m_taxPayer);

cout << endl;

}

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

for (int index=0; index < 5; index++) {

  

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

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

}

}

~

Add a comment
Know the answer?
Add Answer to:
I Need Help. I MUST USED VECTOR OF STRUCTUERS INSTEAD OF AN ARRAY. HOW CAN MAKE...
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
  • 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...

  • Create a C++ project called lab3b and add the following source code init_struct.cpp to the project....

    Create a C++ project called lab3b and add the following source code init_struct.cpp to the project. #include <iostream> #include <string> #include <iomanip> using namespace std; // This program demonstrates partially initialized structure variables // PLACE YOUR NAME HERE struct taxPayer {        string name;        long socialSecNum;        float taxRate; float income; float taxes; }; int main() {        // Fill in code to initialize a structure variable named citizen1 so that        // the first three members are initialized....

  • 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...

  • Modify PartTwo.cpp so that it is uses a vector, named vect, instead of an array. PartTwo.cpp...

    Modify PartTwo.cpp so that it is uses a vector, named vect, instead of an array. PartTwo.cpp Is posted here: // This program reads data from a file into an array. Then, it // asks the user for a number. It then compares the user number to // each element in the array, displays the array element if it is larger. // After looking at entire array, it displays the number of elements in the array larger // than the user...

  • I need help of how to include the merge sort code into this counter code found...

    I need help of how to include the merge sort code into this counter code found below: #include<iostream> using namespace std; int bubble_counter=0,selection_counter=0; // variables global void bubble_sort(int [], int); void show_array(int [],int); void selectionsort(int [], int ); int main() { int a[7]={4,1,7,2,9,0,3}; show_array(a,7); //bubble_sort(a,7); selectionsort(a,7); show_array(a,7); cout<<"Bubble counter = "<<bubble_counter<<endl; cout<<"Selection Counter = "<<selection_counter<<endl; return 0; } void show_array(int array[],int size) { for( int i=0 ; i<size; i++) { cout<<array[i]<< " "; } cout<<endl; } void bubble_sort( int array[],...

  • Using the code below (C++), add a struct with only 1 vector #include #include #include //...

    Using the code below (C++), add a struct with only 1 vector #include #include #include // Needed to define vectors using namespace std; int main() { vector hours; // hours is an empty vector vector payRate; // payRate is an empty vector int numEmployees; // The number of employees int index; // Loop counter // Get the number of employees. cout << "How many employees do you have? "; cin >> numEmployees; // Input the payroll data. cout << "Enter...

  • Create a C++ Console project called Lab3a and add the following source document rect_struct.cpp to the...

    Create a C++ Console project called Lab3a and add the following source document rect_struct.cpp to the project. #include <iostream> #include <iomanip> using namespace std; // This program uses a structure to hold data about a rectangle // PLACE YOUR NAME HERE // Fill in code to declare a structure named rectangle which has // members length, width, area, and perimeter all of which are floats int main() {        // Fill in code to define a rectangle variable named box...

  • How can i make a counter for the number of exchanges made in the linear algorithm?? The binary counter works but the lin...

    How can i make a counter for the number of exchanges made in the linear algorithm?? The binary counter works but the linear doesn't. Here's my code. #include <iostream> using namespace std; void selectionSort(int[], int, int& ); void showSelection(int[], int); void sortArray(int[], int, int&); void showArray(const int[], int); int main() {    int values[25] = { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24...

  • I want to change this code and need help. I want the code to not use...

    I want to change this code and need help. I want the code to not use parallel arrays, but instead use one array of struct containing the data elements, String for first name, String for last name,Array of integers for five (5) test scores, Character for grade. If you have any idea help would be great. #include #include #include #include using namespace std; const int NUMBER_OF_ROWS = 10; //number of students const int NUMBER_OF_COLUMNS = 5; //number of scores void...

  • How can I write this code (posted below) using vectors instead of arrays? This is the...

    How can I write this code (posted below) using vectors instead of arrays? This is the task I have and the code below is for Task 1.3: Generate twenty random permutations of the number 0, 1, 2, ..., 9 using of the algorithms you designed for Task 1.3. Store these permutations into a vector and print them to the screen with the additional information of unchanged positions and number of calls torand(). Calculate the total numbers of unchanged positions. Compare...

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