PRACTICAL NO:-
AIM:-WRITE A PROGRAM IN C++ FOR DISPLAYING TELEPHONE BILL
OF BSNL (Bharat Sanchar Nigam limited) USING MANIPULATOR
ROLL NO:-
====================================================================*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
// CLASS HAVING THE RECORD OF CUSTOMER
class customer//CREAT A CUSTOMER CLASS
{
char ph[10];
char name[30];
char add[40];
char type;
public :
void append();
void display();
}cust;//Declare the class variable
// MAIN FUNCTION HAVING THE MAIN MENU
void main()
{
char ch,ch1;
while(1)
{
clrscr();
cout<
cout<
cout<
cout<
cout<
cout<
cout<
ch =getch();
ch = toupper(ch);
switch(ch)
{
case ('Q') :
clrscr();
exit(1);
case ('D') : cust.display();
break;
case ('A') :cust.append();
break;
}
}
}
// FUNCTION TO ADD THE CUSTOMER RECORD IN THE FILE
void customer :: append()
{
char choice;
fstream fp;
fp.open("tphone.dat", ios::app);
if (!fp)
{
cout<<"Unable to open FILE.";
getch();
return;
}
while(1)
{
clrscr();
cout<
cout<
cout<
while(1)
{
cout<
gets(name);
cout<
if(strlen(name)==0)
{
cout<
}
else
break;
}
while(1)
{
cout<
gets(add);
cout<
if (strlen(add) != 0)
break;
}
while(1)
{
cout<
cin>>ph;
cout<
if (ph != 0 )
break;
}
cout<
cout<
cout<
cin>>type;
fp.write((char *) this,sizeof(cust));
return;
fp.close();
}
}
// FUNCTION TO DISPLAY THE CUSTOMER RECORD AND CALCULATE THE BILL
void customer :: display()
{
char p[10];
char choice;
int found=0;
int no;
float bill, tax, fine, bbill, abill;
fstream fp;
fp.open("tphone.dat", ios::in);
if (!fp)
{
cout<<"Unable to open a file";
getch();
fp.close();
return;
}
while(choice != '0')
{
clrscr();
cout<
cout<
cin>>p;
if (!strcmp(p,"0"))
return;
found = 0;
fp.seekg(0);
while (fp.read((char *)this ,sizeof(cust)))
{
if (found==1)
break;
if (!strcmp(ph,p))
{
clrscr();
cout<
cout<
cout<
cout<
cout<
cout<
cout<
cout<
cout.width(57);
cout<<"Assigned Ph. No.:";
cout<
cout<<"Catagory ( O/R ):";
cout<
cout<
cout<
cout<
cout<<"____";
cin>>no;
if ( no <= 150 )
bill = 0 ;
else
{
no = no - 150;
if (toupper(type) == 'O')
bill = no * 1.00 ;
else
bill = no * .80;
}
cout<
cout<
cout<
cout<
cout<
tax = (5*bill)/100;
cout<
cout<
cout<
cout<
cout<
cout<
int dd,mm,yy;
struct date d; // Getting system Date
getdate(&d);
dd = d.da_day;
mm = d.da_mon;
yy = d.da_year;
cout<
cout<
cout<
bbill = bill+tax+100;
cout<
cout<
cout<
fine = (bbill*5)/100;
cout<
cout<
cout<
cout<
abill = bbill+fine;
cout<
found = 1;
cout<
cout<
cout<
cout<
getch();
}
return;
}
}
fp.close();
}
//end of program
No comments:
Post a Comment