view a text file

Hi guys, here is my program about a carpets company, i did the 2 menus where you can place the order, but in the case 2 i need to show the daily order, and in case 3 i have to show all the orders placed( the are separated by a raw of stars i have already created the text file. it works good, i only need to finish those two little things, can someone help me please, the program is quiet straight forward to understand


#include <iostream>
#include <cctype>
#include <cstdlib>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{



ofstream file1;
file1.open("H:\\new assignment c++\\ALL ORDERS.txt" , ios::app);

int order = 1;

int key = 0;


double num1=0, num2=0, num3=0,num,Totalnum1=0,Totalnum2=0,Totalnum3=0,TotalAmountofSale1=0,TotalAmountofSale2=0,TotalAmountofSale3=0,TotalQuantity=0,TotalSale=0;
int num_customers;
int sentinel=0;
const double UnitPrice1= 100, UnitPrice2= 150,UnitPrice3= 200;
double AmountofSale1=0, AmountofSale2=0, AmountofSale3=0;

double IDnum ;
int choice;


cout<<" WELCOME TO MAGIC CARPET COMPANY \n\n";
cout<<" MENU \n\n";
cout<<" \n\n";
cout<<"1. NEW ORDER \n\n";
cout<<"2. VIEW DAILY ORDERS \n\n";
cout<<"3. VIEW ALL ORDERS \n\n";
cout<<" \n\n";
cout<<" \n\n";
cout<<"4. CLOSE THE PROGRAMM \n\n";
cout<<" \n\n";
cout<<"choise an option from the list above \n\n";
cout<<" \n\n";
cout<<" \n\n";

cin>>choice;
switch(choice)
{
case 1:

system ("cls");


//*********************************************************************************************************************************




//ORDERS MENU


cout<<"___________________MAGIC CARPET COMPANY________________\n\n"
<<"________(1) Red $100*metreSQ__________\n"
<<"________(2) Blu $150*metreSQ__________\n"
<<"________(3) Green $200*metreSQ__________\n";
cout<<"\n";
cout<<"\n";




while (order != sentinel)
{
cout<<"Chose one of the item:\n"<<endl<<endl;
cout<<"[OR PRESS BUTTON 0 TO GO BACK TO THE MAIN MENU]\n"<<endl;


cin>>order;
switch(order)
{

case 0:
return main();

case 1:


cout<<"How many metres would you like to order:\n";
cin>>num1;
Totalnum1=Totalnum1+num1;

AmountofSale1 = UnitPrice1 * num1;
TotalAmountofSale1=TotalAmountofSale1+AmountofSale1;
break;




case 2:
cout<<"How many metres would you like to order:\n";
cin>>num2;
Totalnum2=Totalnum2+num2;

AmountofSale2= UnitPrice2 * num2;
TotalAmountofSale2=TotalAmountofSale2+AmountofSale2;
break;


case 3:
cout<<"How many metres would you like to order:\n";
cin>>num3;
Totalnum3=Totalnum3+num3;

AmountofSale3= UnitPrice3 * num3;
TotalAmountofSale3=TotalAmountofSale3+AmountofSale3;
break;


default: cout<<"Please choose a valid item from our list\n"<<endl;
cout<<"[ press button 0 to end the programm ] \n"<<endl;
}


{
cout<<"\n";
cout<<"You have ordered:\n\n";
cout<<"\n";
cout<<left<<setw(15)<<"ITEM"<<right<<setw(10)<<"QUANTITY"<<right<<setw(15)<<"UNIT PRICE"<<right<<setw(20)<<"AMOUNT OF SALE\n"<<endl;


cout<<"RED CARPET "<<setw(6)<<left<<" "<<Totalnum1 <<setw(16)<<right<< UnitPrice1 <<setw(20) <<right<< TotalAmountofSale1<<endl<<endl;
cout<<"\n";

cout<<"BLU CARPET "<<setw(6)<<left<<" "<<Totalnum2 <<setw(16)<<right<< UnitPrice2 <<setw(20) <<right<< TotalAmountofSale2<<endl<<endl;
cout<<"\n";

cout<<"GREEN CARPET "<<setw(6)<<left<<" "<<Totalnum3 <<setw(16)<<right<< UnitPrice3 <<setw(20) <<right<< TotalAmountofSale3<<endl<<endl;
cout<<"\n";


TotalQuantity=Totalnum1+Totalnum2+Totalnum3;
cout<<"TOTAL QUANTITY = "<<TotalQuantity;
cout<<"\n";

TotalSale=TotalAmountofSale1+TotalAmountofSale2+TotalAmountofSale3;
cout<<"TOTAL PRICE = "<<TotalSale<<endl<<endl<<endl;

file1<<"TOTAL METERS-RED "<<Totalnum1<<" SALE "<<TotalAmountofSale1<<endl;
file1<<"TOTAL METERS-BLU "<<Totalnum2<<" SALE "<<TotalAmountofSale2<<endl;
file1<<"TOTAL METERS-GREEN "<<Totalnum3<<" SALE "<<TotalAmountofSale3<<endl<<endl;
file1<<"TOTAL METERS "<<TotalQuantity<<" TOTAL SALE "<<TotalSale<<endl<<endl;


while(key != 0);



}


}






break;


//*******************************************************************************************************************************************

case 2:










system("cls");

break;



//***************************************************************************************************************************************


case 3:


















system("cls");

break;
//*************************************************************************************************************************************************
case 4:
system("cls");
cout<<"SEE YOU TOMORROW \n\n";
break;


default:
system("cls");
cout<<"Please chose one of the options \n\n";




}


file1.close();


system ("pause");
return 0;

}
It's your homework, maybe you should do it yourself ?

If you have a question, were happy to help!
Topic archived. No new replies allowed.