*/
// Includes
#include<iostream.h> // for << and >>
#include<iomanip.h> // for setw and setf
#include<fstream.h> // for file I/O
#include"apstring.h" // for apstring identifiers
// Function Prototypes
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~ Main Program ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int main ()
{
cout.setf(ios::fixed, ios::floatfield); // Set up floating point
cout.setf(ios::showpoint); // output format
// Declaration and initialization of variables
apstring prices[5]; // array of grades
apstring items[5]; // array of grades
apstring quantities[5]; // array of grades
ifstream old; // Holds the figures
// Open the files
old.open("Ald.txt");
// Get data // Main Function statements
for (int i = 0; i <= 4; i++)
{
old >> items[i];
old >> prices[i];
old >> quantities[i];
}
cout << " item" << " price" << " quantity" << endl;
for (i = 0; i <= 4; i++)
{
cout << i << " " << setw(6) << items[i] << " " << prices[i] << " " << quantities[i] << ' ' << endl;
}
cout << endl;
cout << "Please enter a position value for the price array: ";
cin >> i;
cout << prices[i] << endl;
cout << "Please enter a position value for the quantity array: ";
cin >> i;
cout << quantities[i];
return 0;
}// end main
HERE'S THE PROB.
cout << "Please enter a position value for the quantity array: ";
cin >> i;
cout << quantities[i];
how do i subtract one from the value of quantites[i]?
say quantities[i] = 20
how do i make it equal 19??