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

  • 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[],...

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

  • read in numbers into array , print out, sort - my program reads in and prints...

    read in numbers into array , print out, sort - my program reads in and prints out but crashes before the sort - crashes after it prints out the scores - *important I have to use pointers!!!! c++ #include <iostream> using namespace std; void sortarray(int *tarray, int ); void displayarray(int *[], int); void averageshowarray(int *[], int); int main() {     int Size;     int count;     cout << "enter the size: " << endl;     cin >> Size;     int...

  • I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7:...

    I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7: Customer Accounts Write a program that uses a structure to store the following data about a customer account:      Customer name      Customer address      City      State      ZIP code      Telephone      Account balance      Date of last payment The program should use an array of at least 20 structures. It should let the user enter data into the array, change the contents of any element, and display all the...

  • Hello, I am trying to get this Array to show the summary of NETPAY but have...

    Hello, I am trying to get this Array to show the summary of NETPAY but have been failing. What is wrong? #include <iostream> #include <iomanip> using namespace std; main(){ char empid[ 100 ][ 12 ];    char fname[ 100 ][ 14 ], lastname[ 100 ][ 15 ];    int sum; int hw[ 100 ]; double gp[ 100 ], np[ 100 ], hr[ 100 ], taxrate[100], taxamt[ 100 ]; int counter = 0; int i; cout<<"ENTER EMP ID, FNAME, LNAME, HRS...

  • What did I do wrong with this C++ code? Assume that we don't need to ask...

    What did I do wrong with this C++ code? Assume that we don't need to ask users for the number of students. #include <iostream> #include <iomanip> using namespace std; int main() { float *grades; // a pointer used to point to an array int size; int count = 0; // track the number of grade/student float grade; // the grade of a student float average, total; // average grade and total grades //**************start your code here************************ cout<<"How many student grades...

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
ADVERTISEMENT