#include <iostream>
using namespace std;
const int capacity = 20;
string tax_payers[capacity] = {"jane", "tom", "jerry", "joe", "annie", "mary", "kate", "steve", "sarah", "paul", "petra", "peter","elaine", "noreen", "sean", "niamh", "donal", "john", "marie", "colin"};
double income[capacity] = {21000.0, 16500.0, 120000.0, 16000.0, 38000.0, 62500.0, 14500.0, 28500.0, 13500.0, 27500.0, 15000.0, 44000.0, 18000.0, 21000.0, 150000.0, 15500.0, 40000.0, 21000.0, 25000.0, 37500.0};
void swap(int &j, int &k);
int spaces = 25;
int main()
{
cout << "\t" << "Sorted list" << endl;
for (int j = 0; j < capacity-1; j++)
for(int i = 0; i < capacity-1; i++)
{
if (income[i] < income[i+1])
swap(income[i],income[i+1]);
}
for(int i = 0; i < capacity; i++)
cout << "\t" << tax_payers[i] <<" " << "\t" << income[i] << endl;;
cout << "\n";
cout << "\t" << "Under 25000"<< endl;
for(int i=0;i<capacity;i++)
{
if(income[i] < 25000)
cout << "\t"<< tax_payers[i] << "\n ";
}
cout << "\n";
cout << "\t" << "Over 25000" << endl;
for(int i=0;i<capacity;i++)
{
if(income[i] > 25000)
cout << "\t" << tax_payers[i] << "\n ";
}
return 0;
}
void swap( int &j, int &k )
{
int tmp = j;
j = k;
k = tmp;
}
Sorry bout early post, went wrong my bad. I jst need help to assign the right tax payer and income to the right person for example sean shud b 150000 and not jane, she shud b assigned 21000. Any ideas why it is doin that??