Iam new to c++, iam writing this program with 3 files called header file, class implementation file and main cpp file.
Iam using array to read from 2 files file food Inventory get the data, and other file name rates has tax rates info, i got all the 4 cases working fine, except case 5 I got struck, I really appropriate if you can look at my code, need your help. This is main CPP file , if you want look at other 2 files let me know
inFile >> name >> type >> qty;
while(!inFile.eof())
{
cout << "The input data was: " << endl;
cout << "\tThe name is " << name << endl
<< "\tThe type is " << type << endl
<< "\tThe quantity is " << qty << endl<<endl;
arr[i].setName(name);
arr[i].setCategory(type);
arr[i].setAmount(qty);
i++;
inFile >> name >> type >> qty;
}
int counter=i;
inFile.close();
int sub=0;
for(sub=0; sub<counter; sub++)
{
cout<<"Name="<<arr[sub].getName()
<<" Category="<<arr[sub].getCategory()
<<" Amount="<<arr[sub].getAmount()<<endl;
}
cout << "\n*************************************\n";
cout << "Make a selection from the list below\n";
cout << "*************************************\n";
cout << "1. List all items of a particular category\n";
cout << "2. Find which item has the largest inventory\n";
cout << "3. Find which item has the least inventory\n";
cout << "4. Display the total and average weights\n";
cout << "5. Calculate import taxes\n";
cout << "6. Exit the program:\n";
}
int getChoice()
{
int choice;
cout << "Enter your choice (between 1 and 6): ";
cin >> choice;
cin.ignore();
return choice;
}