Coding of Project
Coding of Project
Coding of Project
h>
#include<conio.h> //For console input-output functions.
#include<stdio.h> //For standard input-output functions.
#include<stdlib.h> //For free();,etc.
#include<process.h> //For exit();
#include<iomanip.h> //For hex();,etc.
#include<string.h> //For strcmpi();,etc.
int i;
void About();
void ViewReport();
/* -----------------------------------------------------------------------------
CLASS NAME : Tenant
DETAILS : IT CONTAINS ALL INFORMATION REGARDING
THE TENANT AND HIS/HER BACKGROUND
--------------------------------------------------------------------------------
*/
// class starts
class tenant //Program starts.
{
private: //declaring variables
char Name[40];
char Father[57];
int Flat;
char Block;
int Age;
int Maintenance;
char PermAddress[100];
char Occupation[20];
char ContactNo[11];
char Description[100];
char CriminalRecord[50];
char witnessname[25];
void generate();
public:
char TenantID[10];
long DueAmount;
char Bock();
char* checkID();
int Rent();
void getdata();
void putdata();
void modif();
void PrintSumary();
void PrintSummary();
}; //class ends.
above ";
cout<<"\nEnter the flat number again";
goto lb99;
}
cout<<"\nBlock Name(A/B/C) -> ";
cin>>Block;
generate();
cout<<"\nMaintenance Paid(Rs) -> ";
cin>>Maintenance;
cout<<"\n Tenant Age(19-85) -> ";
cin>>Age;
if(Age<18||Age>85)
{
cout<<"\nSorry!! we give flats on rent only to people of age
cout<<"\n*****************************************************
*********";
cout<<"\nYour Tenant ID is: "<<TenantID<<endl;
}
void tenant::putdata() //function to display data.
{ char ch,gh;
cout<<"\n*****************************************************
*********";
cout<<"\n Tenant ID: "<<TenantID;
cout<<"\n Name: "<<Name;
cout<<"\n Father name: "<<Father;
cout<<"\n Tenant Age; "<<Age;
cout<<"\n\n To see personal info press 'Y' else 'N'";
ch=getche();
if(ch=='y'||ch=='Y')
{
cout<<"\n Permanent Address: "<<PermAddress;
cout<<"\n Occupation: "<<Occupation;
cout<<"\n ContactNo: "<<ContactNo;
cout<<"\n Description: "<<Description;
cout<<"\n Criminal Record: "<<CriminalRecord;
}
cout<<"\n\n To see flat info press 'Y' else 'N'";
gh=getche();
if(gh=='y'||gh=='Y')
{
cout<<"\n Flat Number: "<<Flat;
cout<<"\n Block : "<<Block;
cout<<"\n Rent Paid: "<<DueAmount;
cout<<"\n Maintenance :"<<Maintenance;
}
}
void tenant::modif() //function to modify data.
{ lb8:
cout<<"\n Tenant Name -> ";
gets(Name);
cout<<"\n Father Name -> ";
gets(Father);
lb99:
cout<<"\n Flat Number(1-150) -> ";
cin>>Flat;
if(Flat<1||Flat>150)
{
cout<<"\nKindly mention flat numbers acc. to range mentioned
above ";
cout<<"\nEnter the flat number again";
goto lb99;
}
cout<<"\nBlock Name(A/B/C) -> ";
cin>>Block;
cout<<"\nMaintenance Paid(Rs) -> ";
cin>>Maintenance;
cout<<"\n Tenant Age(19-85) -> ";
cin>>Age;
if(Age<18||Age>85)
{
cout<<"\nSorry!! we give flats on rent only to people of age
\t"<<Father<<"\t\t"<<DueAmount;
}
void tenant::PrintSummary()
{ cout<<endl<<Block<<"\t\t"<<TenantID<<" \t
\t"<<Name<<"\t\t"<<Flat<<"\t\t"<<Maintenance;
}
char* tenant::checkID()
{return TenantID;
}
int tenant::Rent()
{
return Maintenance;
}
char tenant::Bock()
{
if(Block=='a')
{Block='A';}
if(Block=='b')
{Block='B';}
if(Block=='c')
{Block='C';}
return Block;
}
void AddRecord() //function to add records of new tenant.
{ clrscr();
tenant T;
ofstream file;
cout<<"\n --- ENTER THE INFORMATION FOR A NEW
RECORD ---";
cout<<"\n---------------------------------------------------------------------------"
;
file.open("Tenant.dat",ios::binary|ios::out|ios::app); //To open
file.
T.getdata();
file.write((char*)&T,sizeof(T)); //To read data.
file.close();
cout<<"\n Tenants record successfully added
..........................................";
}
void EditRecord() //function to edit records of an existing tenant.
{ clrscr();
tenant T33;
ifstream fin;
ofstream fout;
char id[10],po;
int f=0;
cout<<"\n";
cout<<"ENTER RECORD ID TO EDIT >> ";
gets(id);
fin.open("Tenant.dat",ios::binary|ios::in); //To open file.
if(!fin)
{cout<<"Sorry!! the file does not exists";
}
fout.open("Modiftenant.dat",ios::binary|ios::out|ios::app);
from file.
while(!fin.eof())
{
if(strcmp(T33.checkID(),id)==0)
{
cout<<" ********* ENTER NEW
-----------------------------------------";
cout<<"\n Tenant ID whose record is to
-----------------------------------------";
cout<<"\n Record has been updated
sucessfully.....";
f=1;
}
else
{ fout.write((char*)&T33,sizeof(T33));
file.
if(!file) //To search till the file ends.
{cout<<"Sorry!! the file does not exists";
}
file.read((char*)&T4,sizeof(T4)); //To read data from the file.
while(!file.eof())
{
if(strcmp(T4.checkID(),id)==0)
{ f=1;
}
else
{
buf.write((char*)&T4,sizeof(T4)); //To
}
fin.read((char*)&T5,sizeof(T5)); //To read data from the
file.
while(!fin.eof()) //To search till the file ends.
{
if(strcmp(T5.checkID(),id)==0)
{
int amt;
cout<<"\nCurrent Rent ->"<<"
"<<T5.DueAmount;
cout<<"\n\nEnter adjustment amount
->";
cin>>amt;
cout<<"\nThe adjustment amount
sucessfully.....";
f=1;
}
else if(se=='2')
{
T5.DueAmount=T5.DueAmount-amt;
fout.write((char*)&T5,sizeof(T5));
//To write data on the file.
cout<<"\n\nRent updated
sucessfully.....";
f=1;
}
else
{cout<<"\nWrong choice entered.......";
goto lb3;
}
}
else
{ fout.write((char*)&T5,sizeof(T5)); //To write
DETAILS.............>>";
gets(id);
file.open("Tenant.dat",ios::binary|ios::app); //To open the
file.
if(!file)
{cout<<"Sorry!! the file does not exists";
}
while(!file.eof()) //To search till the end of the
file.
{
file.read((char*)&T2,sizeof(T2));
if(strcmp(T2.checkID(),id)==0)
{ T2.putdata();
cout<<endl;
f=1;
break;
}
}
file.close(); //To close the file.
if (f==0)
{
cout<<"\n";
cout<<" Reached End-of-Datafile...";
cout<<endl<<endl;
cout<<" NO SUCH RECORD EXISTS...";
}
}
void ViewReport() //function to display rent paid (ID wise).
{ clrscr();
tenant T1;
ifstream file;
file.open("Tenant.dat",ios::binary|ios::in); //To open the file.
cout<<"\n\t\t";
cout<<" ************TENANT-ID WISE DUE RENT
cout<<"\n---------------------------------------------------------------------";
cout<<endl;
cout<<" TENANT-ID|\t TENANT NAME|\t FATHER NAME|
\t RENT PAID";
cout<<endl;
cout<<"-----------|\t------------|\t-------------|\t---------------";
file.read((char*)&T1,sizeof(T1)); //To read data from the
file.
while(!file.eof()) //To search till the end of the
file.
{
if(file.eof())
break;
T1.PrintSumary();
file.read((char*)&T1,sizeof(T1)); //To read data
cout<<"\n-------------------------------------------------------------------";
cout<<"\n Reached End-of-Datafile...................................";
file.close(); //To close the file.
}
void IncomeReport() //function to show income of the society from
(Rs.)";
cout<<endl;
cout<<"-----------|\t\t-------------- | -------------\n";
file.read((char*)&T21,sizeof(T21)); //To read data from
the file.
while(!file.eof()) //To search till the end of the file.
{
strcpy(l,T21.checkID());
m=T21.Rent();
n=T21.DueAmount;
t+=m;
s+=n;
cout<<l<<"\t\t\t"<<m<<"\t\t\t"<<n<<endl;
file.read((char*)&T21,sizeof(T21)); //To read
data from the file.
}
cout<<"\n---------------------------------------------------";
cout<<"\nTotal Income from Maintenance ="<<t;
cout<<"\nTotal Income from Rent ="<<s;
file.close(); //To close the file.
}
void BlockReport() //function to see report of a renant block
wise.
{ clrscr();
tenant T11;
char bg;
ifstream file;
file.open("Tenant.dat",ios::binary|ios::in); //To open the file.
cout<<"\nEnter Block name whose report is to be viewed :";
cin>>bg;
cout<<"\n\t\t";
cout<<" *********BLOCK- WISE DUE MAINTENANCE
file.
while(!file.eof()) //To search till the end of the file.
{
if(T11.Bock()==bg)
T11.PrintSummary();
file.read((char*)&T11,sizeof(T11)); //To read
the society.
{ char g;
clrscr();
cout<<"\n----------------------------FLATS AND
FAMILIES----------------------------------\n"
<<"\nThe Society is divided in 3 Blocks A,B and
is.. \n"
<<"\n*Press 1->GO BACK\t\t\t*Press any key-
>TO TERMINATE\n";
cin>>g;
if(g=='1')
{About();} //Function call.
}
void Facilities() //function to display facilities provided by the society.
{ char g;
clrscr();
cout<<"\n--------------------------OTHER
FACILITIES------------------------------------\n"
<<"\nThe Society has a swimming pool in the
>TO TERMINATE\n";
cin>>g;
if(g=='1')
{About();} //Function call.
}
void Contact() //function to display contact information of members of
society parliament.
{ char p;
clrscr();
cout<<"\n\t****************CONTACT
US**************************"
<<"\nMr.Madan Khatri"
<<"\nSociety President"
<<"\n9832167865"
<<"\[email protected]"
<<"\nFlat: C-14 "
<<"\n\nMr.Bitto Kumar"
<<"\nSociety Vice President "
<<"\n9721867865"
<<"\[email protected]"
<<"\nFlat: A-11"
<<"\n\nMr.Abhijeet Das"
<<"\nSociety Secretary"
<<"\n9832167865"
<<"\[email protected]"
<<"\nFlat: B-18"
<<"\n\nSociety E-mail"
<<"\[email protected]"
<<"\nTelephone-01123346578"
<<"\n\t\t\t\tPress any key----------------> ";
p=getche(); //To accept a character.
}
void Parks() //function to display information about the parks in the
society.
{ char g;
clrscr();
cout<<"\n--------------------------
PARKS-----------------------------------------\n"
<<"\nThe Society has 3 parks in total, one near the
entrance, one near the B block\n"
<<"\nand one near the Temple.One of the parks is
society.
{ char g;
clrscr();
cout<<"\n-------------------------SECURITY
SERVICES-----------------------------------\n"
<<"\nThe Society has high security services for the
>TO TERMINATE\n";
cin>>g;
if(g=='1')
{About();} //Function call.
}
void About() //function to show the menu "About the society".
{ clrscr();
int q;
cout<<"\n***********************About the
society**************************"
<<"\n1..FLATS AND FAMILIES"
<<"\n2..PARKS"
<<"\n3..SECURITY"
<<"\n4..OTHER FACILITIES"
<<"\n5..BACK TO MAIN MENU"
<<"\nEnter your choice(1-5)...>> ";
cin>>q;
switch(q)
{
case 1: Flat(); //Function call.
break;
case 2: Parks(); //Function call.
break;
case 3: Security(); //Function call.
break;
case 4: Facilities(); //Function call.
break;
case 5: break;
default: cout<<"Sorry!!! wrong choice
entered ";
About();
}
}
void main() //main function starts.
{ char k;char ch,pk,h;
clrscr(); // Menu to select colors.
cout<<"\n************************Welcome To Heavens
Gate Society*********************\n";
A:
int t;
cout<<"\nEnter color code (1-6)\n1.Dark Blue\n2.Green
**********************";
cout<<"\n---------------------------------------------";
cout<<"---------------------------------------------";
call.
break;
call.
break;
case '3': EditRecord(); //Function call.
break;
break;
break;
call.
break;
call.
break;
call.
break;
break;
Exit....";
character.
exit(-1);
default: cout<<"\n \n
Oops!!!.......INVALID SELECTION";
cin>>h;
if((h=='N')||(h=='n'))
(Y/y)\n";
cin>>pk;
if((pk=='Y')||(pk=='y'))
goto A;
else exit(-1);
}while((h=='y')||(h=='Y'));
getch();
//Program ends