// 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
float prices[5]; // array of grades
apstring items[5]; // array of grades
int 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] << " " << setprecision(2) << 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] -1) << endl;
int j; // array place
cout << "Please enter a position value to enter the info to arrays: ";
cin >> j;
for ( j; j <= 4; j++)
{
items[j]=items[j+1];
prices[j]=prices[j+1];
quantities[j]=quantities[j+1];
}
cout << "Enter the item (Notebook): ";
cin >> items[j];
cout << endl;
cout << "Enter the price (1.55): ";
cin >> prices[j];
cout << endl;
cout << "Enter the quantity (50): ";
cin >> quantities[j];
cout << endl;
cout << " item" << " price" << " quantity" << endl;
for (i = 0; i <= 5; i++)
{
cout << i << " " << setw(6) << items[i] << " " << prices[i] << " " << quantities[i] << ' ' << endl;
}
cout << endl;
return 0;
}// end main
cout << "Please enter a position value to enter the info to arrays: ";
cin >> j;
for ( j; j <= 4; j++)
{
items[j]=items[j+1];
prices[j]=prices[j+1];
quantities[j]=quantities[j+1];
}
cout << "Enter the item (Notebook): ";
cin >> items[j];
cout << endl;
cout << "Enter the price (1.55): ";
cin >> prices[j];
cout << endl;
cout << "Enter the quantity (50): ";
cin >> quantities[j];
cout << endl;
i'm an entering new info into say the 3 array element place....how do i make the old 3 information move to 4 and old for to 5??