i need to creat a function that will read information from a data file, and store the bank accounts in two seperate parrarell arrays. array “account”, and store the balance on the accounts in array “balance”.
here is an example of what i have to do
<data file>
231 4000.52
345 10000.00
541 500.00
231 100.00
541 200.00
541 1400.00
the data file should be added to the arrays which should give me the data
“account” “balance”
231 5500.52
345 10000.00
541 2100.00
Here is basic idea of what i have been trying to get to work(ps. the data file contains 3000 lines of data but their is only 100 account numbers)
int TemporaryID;
int TemporaryBalance;
int index;
while(indata>>temporaryID>>temporaryBalance)
{
for(int i=0 ; i < array_size ; i++)
{
indata>>temporaryID>>temporaryBalance;
index=linearSearch(account, array_size, temporaryID)
if(index<0)
{
account[i]=temporaryID;
balance[i]=temporaryBalance;
}
else
balance[index]+=temporaryBalance;
}
}//end of main
//the function linear search
int linearSearch(const int array[], size, findnumber)
{
for (int i = 0; i < size; i++)
if (array[i] == findnumber)
return i;
return -1;
}
I CANT GET THE PROPER INPUT FOR MY ARRAYS AND I DONT KNOW WHY... PLZ HELP