0% found this document useful (0 votes)
18 views6 pages

Include

This C++ program defines a Customer class with fields like name, address, phone number, payment amounts and dates. It allows entering customer data, storing it in an array of objects. The data is outputted to the console and written to a file stream. Key concepts used are OOP, classes, streams and file I/O to read from and write objects to a file.

Uploaded by

Muhammad Adil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views6 pages

Include

This C++ program defines a Customer class with fields like name, address, phone number, payment amounts and dates. It allows entering customer data, storing it in an array of objects. The data is outputted to the console and written to a file stream. Key concepts used are OOP, classes, streams and file I/O to read from and write objects to a file.

Uploaded by

Muhammad Adil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

#include<iostream>

#include<fstream>
#include<string.h>
#include<ctime>
using namespace std;
class CBS{
public:
char name[80];
char address[80];
double ph_n;
double paid_amount;
double due_amount;
time_t payment_date;
CBS()
{
payment_date=time(0);
}
void get()
{
cout<<" Enter Name of customer :: "; cin>>name;
cout<<" Enter Address of customer :: "; cin>>address;
cout<<" Enter Phone.number of customer :: "; cin>>ph_n;
cout<<" Enter paid amount of customer :: ";
cin>>paid_amount;
cout<<" Enter Due amount of customer :: ";
cin>>due_amount;
}
void put()
{
cout<<"----------------------------------------------------------------"<<endl;
cout<<"Name Address ph.no piad_amount
due_amount"<<endl<<endl;
cout<<name<<" "<<address<<" "<<ph_n<<"
"<<paid_amount<<" "<<due_amount<<endl<<endl;
char* dt=ctime(&payment_date);
cout<<"the local date ::"<<dt<<endl;
cout<<"---------------------------------------------------------------"<<endl;
}
};
int main()
{
char x;
cout<<"press any letter to enter:: ";
cin>>x;
if(x){
cout<<" START ENTERINIG DATA OF ANY CUSTOMER\n";
CBS* ptr[200];
int n=0;
char choice;
ofstream outfile;
outfile.open("file.doc");
do{
ptr[n]=new CBS;
ptr[n]->get();
outfile<<"----------------------------------------------------------------
"<<endl;
outfile<<" Name Address ph.no piad_amount
due_amount"<<endl<<endl;
outfile<<ptr[n]->name<<" "<<ptr[n]->address<<" "<<ptr[n]-
>ph_n<<" "<<ptr[n]->paid_amount<<" "<<ptr[n]-
>due_amount<<endl<<endl;
char* dt=ctime(&(ptr[n]->payment_date));
outfile<<"date of payment ::"<<dt<<endl;
outfile<<"---------------------------------------------------------------"<<endl;
cout<<"/nEnter another Customer (y/n)? ";
cin>>choice;
}
while(choice=='y');
}
}
LAB REPORT
We have used all the concept of oop in this lab that we have studied
very well in the class. The new concept we have used there is the
concept of stream and file.
A. Stream: stream is something which worked
as interface between input and output in
library IOSTREAM.
And in FSTREAM it worked as an
interface between file and program.

we have used FSTREAM libray for storing the data of program on the file
and for reading the data from the file to the program.
There two special stream inside the FSTREAM which are given below.
B. Ifstream :: This is for reading the value from
the file.
C. Ofstream :: This for Writing the value on
the file.

You might also like