Question
Hello, I'm working on a C++ project and am getting a few errors here, mostly need help with the loadArray function and the look up
Hello, I'm working on a C++ project and am getting a few errors here, mostly need help with the loadArray function and the look up taxes function. Here is my code so far:
#include #include #include #include using namespace std;
//Functions void displayAddressesAmtDue(string[], double[], int); void sortDisplayAddressTaxDue(string[], double[], int); void lookUpTaxes(string[], double[], int); void displayLargestDelTaxBill(string[], double[], int); void loadArrays(string[], double, int &); //globals const int SIZE = 7; string address[7]; double amtDue[7];
int loadArrays(string address[], double amtDue[], int length) { int count = 0; ifstream loadTaxes; loadTaxes.open("prog3.txt"); if (loadTaxes.fail()) { // this will alert user if there is a problem opening the file cout << "Error opening the file "; return 0; } for (int i = 0; i < length; i++) { std::getline(loadTaxes >> std::ws ,address[i]); loadTaxes >> amtDue[i]; cout << address[i] << endl; cout << "$" << amtDue[i] << endl; } } //Show menu function void showMenu() { int choice; //menu choice do { //display menu cout << "----------------------------------------------------------- "; cout << "County Auditor Database Search Menu: "; cout << endl; cout << "Enter 1 = All Taxes and Properties " << "Enter 2 = Due taxes (Ascending) " << "Enter 3 = Display largest balance " << "Enter 4 = Address look-up " << "Enter 5 = Close County Auditor Search Program " << "Selection: "; cout << "----------------------------------------------------------- "; cin >> choice; cout << endl;
//validate user's choice while (choice < 1 || choice > 5) { cout << "Enter a valid selection: "; cin >> choice; }
//process user's choice if (choice != 5) { //respond with user's menu selection switch (choice) { case 1: displayAddressesAmtDue(address, amtDue, SIZE); break; case 2: sortDisplayAddressTaxDue(address, amtDue, SIZE); break; case 3: displayLargestDelTaxBill(address, amtDue, SIZE); break; case 4: lookUpTaxes(address, amtDue, SIZE);
} }
} while (choice != 5); }
int main() {
showMenu();
return 0; }
//Function to Display all properties and tax bills void displayAddressesAmtDue(string address[], double due[], int properties) { int i = 0; cout << "All current accounts (address & amount due): ";
for (i = 0; i < properties; i++) { cout << address << setw(4) << "\t= $" << setprecision(2) << fixed << due; cout << endl; } system("pause"); cout << " "; }
//Function to sort taxes and addresses in ascending order void sortDisplayAddressTaxDue(string address[], double due[], int properties) { int minIndex, index = 0; string minValue2; double minValue1 = 0;
//sort taxes due for (int startScan = 0; startScan < (properties - 1); startScan++) { minIndex = startScan; minValue1 = due[startScan];
for (index = startScan + 1; index < properties; index++) { if (due[index] < minValue1) { minValue1 = due[index]; minIndex = index; minValue2 = address[index]; } } due[minIndex] = due[startScan]; due[startScan] = minValue1; address[minIndex] = address[startScan]; address[startScan] = minValue2; }
//display addresses and taxes due int i = 0;
cout << "These are the sorted addresses and their tax bills due ";
for (i = 0; i < properties; i++) { cout << address << setw(4) << "\t = $ " << setprecision(2) << fixed << due; cout << endl; } system("pause"); cout << " "; }
//Function to Display largest tax bill void displayLargestDelTaxBill(string address[], double due[], int properties) { int minIndex, index = 0; string minValue2; double minValue1 = 0;
//This sorts taxes due for (int startScan = 0; startScan < (properties - 1); startScan++) { minIndex = startScan; minValue1 = due[startScan];
for (index = startScan + 1; index < properties; index++) { if (due[index] < minValue1) { minValue1 = due[index]; minIndex = index; minValue2 = address[index]; } } due[minIndex] = due[startScan]; due[startScan] = minValue1; address[minIndex] = address[startScan]; address[startScan] = minValue2; } cout << "The property with the largest tax bill due is " << address[properties - 1] << " = $ " << setprecision(2) << fixed << due[properties - 1]; cout << endl; system("pause"); cout << " "; }
//Function to Look up Taxes by user input void lookUpTaxes(int amtDue[], string address[]){ string searched; cout<<"Enter Address to search: "; cin.ignore(); getline(cin, searched); int i; bool notFound=true; for(i=0;i { if(searched == address[i]) { cout<< fixed < cout<<"Tax details "; cout<<"Address: "< cout<<"Taxes: $"< notFound=false; } } if(notFound) { cout<<"Tax details not found "; system("pause"); }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started