C0142 and C2109 errors on C++

  • Thread starter Thread starter Brian Holcer
  • Start date Start date
B

Brian Holcer

Guest
I keep getting these error on my amtDue array in the description of the functions that use the array. Can some tell me what it is and how to fix?

Thanks,

Brian

# include <iostream>
# include <fstream>
# include <string>
using namespace std;
void loadArrays(string[], double[], int);
void showArrays(string [], double[], int);
void lookUpTaxes(string[], double[], int);
void sortTaxes(string [], double[], int);
void biggestTaxes(string[],double[], int);
int showMenu();
void sortTaxes(string address, double amtDue, int SIZE);
void swap(string a, string b);
void swap(double a, double b);
int main()
{
int const SIZE = 8;
string address[SIZE];
double amtDue[SIZE];
ifstream inputFile;
inputFile.open("prog3.txt");
int count;
for (count=0;count<SIZE; count++)
{
inputFile >> address[count] >> amtDue[count];
}
inputFile.close();
loadArrays(address, amtDue, SIZE);
int choice;
showMenu();
while (choice != 5)
{
if (choice == 1)
{
showArrays(address, amtDue, SIZE);
}
else if (choice == 2)
{
lookUpTaxes(address, amtDue, SIZE);
}
else if (choice == 3)
{
sortTaxes(address, amtDue, SIZE);
}
else if (choice == 4)
{
biggestTaxes(address, amtDue, SIZE);
}
else
cout << "Invalid choice- try again: ";
choice = showMenu();
}
return 0;
}
int showMenu()
{
int choice;
cout << "County Auditor Property TaxSearch and Sort" << endl;
cout << "1. Display Property Tax Data" << endl;
cout << "2. Look up taxes for a particular address" << endl;
cout << "3. Sort tax amounts in ascending order" << endl;
cout << "4. Display property with largest tax due" << endl;
cout << "5. Exit" << endl;
cout << "Please enter your selection; " << choice << endl;
return choice;
}
void loadArrays(string address, double amtDue, int SIZE)
{
int count;
for (count = 0; count < SIZE; count++)
address[count]>>amtDue[count];

}
void showArrays(string address, double amtDue, int SIZE)
{
for (int count = 0; count < SIZE; count++)
cout << address[count] << "-" << "$" << amtDue[count] << endl;
}
void lookUpTaxes(string address, double amtDue, int SIZE)
{
cout << "Enter the address you are looking up : " << address << endl;
int first = 0, number, last = number - 1, middle, position = -1,value;
bool found = false;
while (!found && first < +last)
{
middle = (first + last) / 2;
if (address[middle] == value)
{
found = true;
position = middle;
}
else if (address[middle] > value)
last = middle - 1;
else
first = middle + 1;
}
cout << "The taxes for " << address[middle] << " is $" << amtDue[middle];
}
void sortTaxes(string address, double amtDue, int SIZE)
{
int start, minIndex;
string tempStart;
double minValue;
for (start = 0; start < (SIZE - 1); start++)
{
minIndex = start;
tempStart = address[start];
minValue = amtDue[start];
for (int index = start + 1; index < SIZE; index++)
{
if (address[index] < minValue)
{
tempStart = address[index];
minValue = amtDue[index];
minIndex = start;
}
swap(address[minIndex], address[start]);
swap(amtDue[minIndex], amtDue[start]);
}
}

}
void swap(string a, string b)
{
string temp= a;
a = b;
b = temp;
}
void swap(double a, double b)
{
double temp=a;
a = b;
b = temp;
}

void biggestTaxes(string address, double amtDue, int SIZE)
{
int start, maxIndex;
double maxValue;
string tempStart;
for (start = 0; start < (SIZE - 1); start++)
{
maxIndex = start;
tempStart = address[start];
maxValue = amtDue[start];
for (int index = start + 1; index < SIZE; index++)
{
if (amtDue[start] > maxValue)
{
tempStart = address[index];
maxValue = amtDue[index];
maxIndex = index;
}

swap(address[maxIndex], address[start]);
swap(amtDue[maxIndex], amtDue[start]);
cout << "The property with the largest tax due is : " << amtDue[maxValue] << "at " << address[maxValue] << endl;
}

}
}

Continue reading...
 

Similar threads

B
Replies
0
Views
102
Brian Holcer
B
A
Replies
0
Views
186
Arash_89
A
A
Replies
0
Views
153
abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL
A
Back
Top