hi....

may i know how data file handling can be used in a program such as the one below.... please suggest.


#include<iostream.h>
#include<conio.h>
#include <ctype.h>
#include<stdlib.h>
#include<stdio.h>
#include<graphics.h>
float b=1000;
void main()
{




clrscr();





double total = 0;
double amount;
double temp;
char choice;




cout << "\nwelcome 2 my grocery store!!!!";
cout << "\nwould u like 2 see the items available for purchase(y/n)? ";
cin >> choice;
cin.get();
if ( choice == 'Y' || choice == 'y' )
{

do
{
//the display menu
cout << "the items available are:";
cout << "\nno. "<<'\t'<<"item "<<'\t'<<"quantity(b)(in grams)"<<'\t'<<"m.r.p(c)";
cout << "\n--- "<<'\t'<<"---- "<<'\t'<<"---------------------"<<'\t'<<"--------";
cout << "\n1. "<<'\t'<<"urad dal "<<'\t'<<"1000g "<<'\t'<<"Rs.50.25";
cout << "\n2. "<<'\t'<<"tur dal "<<'\t'<<"1000g "<<'\t'<<"Rs.60.75";
cout << "\n3. "<<'\t'<<"tea powder "<<'\t'<<"1000g "<<'\t'<<"Rs.200.0";
cout << "\n4. "<<'\t'<<"rice "<<'\t'<<"1000g "<<'\t'<<"Rs.50.00";


cout << "\n enter choice...... => ";
cin >> choice;
cin.get();


if( choice == '1' )
{
cout << "\nenter the amount of the item u want to purchase ";
cin >> amount;
temp = ( amount * 50.25 ) / 1000.00;
total = temp + total;
cout << "\n the amount to be paid is:" << temp << "\n";
}
else if( choice == '2' )
{
cout << "\nenter the amount of item ";
cin >> amount;
temp = ( amount * 60.75 ) / 1000.00;
total = temp + total;
cout << "\nthe amount 2 b paid is:" << total << "\n";
}
else if( choice == '3' )
{
cout << "\nenter the amount of item ";
cin >> amount;
temp = ( amount * 200.00 ) / 1000.00;
total = temp + total;
cout << "\nthe amount 2 be paid is:" << total << "\n";
}
else if(choice == '4')
{
cout<< "\nenter the amount of item";
cin>>amount;
temp= ( amount * 50.00 )/1000.00;
total = temp + total;
cout<< "\nthe amount 2 be paid is:" << total<<"\n";
}
else
cout<<"\u've entered the wrong choice!!!! item does not exist";
cout << "\ndo u want to buy another item? ";
cin >> choice;
cin.get();
} while ( choice == 'y' || choice == 'Y' );

cout<<"\nplease wait.... ur bill is being calculated...." << endl;
cout << "the total is " << total << endl;


cout << "\nplease pay the requested amount,that is Rs."<<total<<"." << endl;


cout<<"\nthanks for visiting my store !!!" << endl;

}

}
}

getch();
}





Last edited on
hi...

code tags would be nice, thx...
enclose your code with code tags please [code][/code] to be read easily. and are you still using the old turbo C?
Maaaaaan I remember turbo C!! That thing was so cool back in the day! Anyways for data file handling you need filestream stuff aka fstream.
http://cplusplus.com/reference/iostream/fstream/

I think you may just try using iostream too.
http://cplusplus.com/iostream
Topic archived. No new replies allowed.