Need help please

Write your question here.
can someone plz help me do the print case 4 and save case 5, i cant still do that part..

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>


using namespace std;

int main()
{
void printInventory (ofstream& myFile2, string inventoryArray[], int sizeArray[]);

int choice;
string fileName;
ifstream myFile;
ofstream myFile2;


vector<string> inventoryDescription;
vector<string> inventoryNumber;

vector<string>::const_iterator it;

string description;
string number;
int size = 0;
double price;
int quantity;
double total;


while(1)
{

cout<<endl;
cout<< "+-------------------------------------+" <<endl;
cout<< "| Main Menu: |" << endl;
cout<< "| -------------- |" << endl;
cout<< "| |"<< endl;
cout<< "| 1) Load |" << endl;
cout<< "| 2) Add |" << endl;
cout<< "| 3) Search |" << endl;
cout<< "| 4) Print |" << endl;
cout<< "| 5) Save |" << endl;
cout<< "| 6) Exit |" << endl;
cout<< "+-------------------------------------+" <<endl;
cout<<endl;
cout << "Enter your choice:";
cin >> choice;

switch(choice)
{

{
case 1:

cout << "Please, enter the name of the file you would like to open? ";
cin >> fileName;


myFile.open(fileName.c_str());

if (myFile.fail())
{
cerr << "File Not Found";
exit(1);
}
else
{
cout << "File has successfully loaded..." << endl;
}

break;
}

case 2:

{
myFile2.open(fileName.c_str(),ios::app);
string inputBuffer;
getline(cin, inputBuffer);
cout << "Enter inventory number for new data: ";
cin.ignore();
getline(cin, number);

inventoryNumber.push_back(number);
sort(inventoryNumber.begin(), inventoryNumber.end());

cout << "Enter an item description: ";
cin.ignore();
getline(cin, description);

inventoryDescription.push_back(description);
sort(inventoryDescription.begin(), inventoryDescription.end());

cout << "Enter the quantity: ";
cin>>quantity;

cout << "Enter an item price: ";
cin >> price;

total=quantity*price;
myFile2 << number << endl;
myFile2 << description << endl;
myFile2 << quantity << endl;
myFile2 << price <<endl;
myFile2 << total <<endl;


myFile2.close();
break;
}
case 3:
{

int invNumS;

cout << "Enter the inventory number of the item to search: ";
cin>> invNumS;


for (vector<string>::iterator i = inventoryNumber.begin(); i != inventoryNumber.end(); i++)
{
if (invNumS == inventoryNumber.size())
{
cout << "Data for item number : " << invNumS<< endl;
cout << "Item description : " << inventoryDescription.size() << endl;
cout << "Quantity: " << quantity<<endl;
cout << "Price: " << price << " $ "<< endl;
cout << "Total: " << total << endl;
}

else
{
cout << invNumS<<"Not Found"<<endl;
}

}

break;

}

case 4:
{

int i;
for (i=0; i<15; i++)
{
cout << i << "****************" << endl;

if (i % 15 == 14)
{
system("pause");
system("cls");
}
}


}
case 5:
{


}
case 6:
{
exit(0);
}
default:
{
cout << "You entered an invalid option" << endl;
}
}


}
}
Topic archived. No new replies allowed.