Professors of different subjects define the same word in different ways:
Prof. of Computer Science: A kiss is a few bits of love compiled into a byte.
Prof. of Algebra: A kiss is two divided by nothing.
Prof. of Geometry: A kiss is the shortest distance between two straight lines.
Prof. of Physics: A kiss is the contraction of mouth due to the expansion of the heart.
Prof. of Chemistry: A kiss is the reaction of the interaction between two hearts.
Prof. of Zoology: A kiss is the interchange of unisexual salivary bacteria.
Prof. of Physiology: A kiss is the juxtaposition of two orbicularis oris muscles in the state of contraction.
Prof. of Dentistry: A kiss is infectious and antiseptic.
Prof. of Accountancy: A kiss is a credit because it is profitable when returned.
Prof. of Economics: A kiss is that thing for which the demand is higher than the supply.
Prof. of Statistics: A kiss is an event whose probability depends on the vital statistics of 36-24-36.
Prof. of Philosophy: A kiss is the persecution for the child, ecstasy for the youth and homage for the old.
Prof. of English: A kiss is a noun that is used as a conjunction; it is more common than proper; it is spoken in the plural and it is applicable to all.
Prof. of Engineering: Uh, What? I'm not familiar with that term.
Friday, October 15, 2010
Thursday, October 14, 2010
The Salary Theorem . . .
Dilbert's "Salary Theorem" states that "Engineers
and scientists can never earn as much as business executives and
marketing people."
This theorem can now be supported by a mathematical
equation based on the following two postulates:
1: Knowledge is Power.
2: Time is Money.
As every engineer or scientist knows:
Power = Work / Time ---------------(1)
also Knowledge = Power -----------------(2)
and Time = Money ----------------------(3)
Therefor from eqs. 1, 2 and 3 we can say that :
Knowledge = Work/Money
Solving the above equation for the value of Money, we get:
Money = Work / Knowledge
Thus, it is clear from the above equation that as Knowledge approaches
zero, Money approaches infinity, regardless of the amount of work done.
Conclusion: The less you know, the more you make.
and scientists can never earn as much as business executives and
marketing people."
This theorem can now be supported by a mathematical
equation based on the following two postulates:
1: Knowledge is Power.
2: Time is Money.
As every engineer or scientist knows:
Power = Work / Time ---------------(1)
also Knowledge = Power -----------------(2)
and Time = Money ----------------------(3)
Therefor from eqs. 1, 2 and 3 we can say that :
Knowledge = Work/Money
Solving the above equation for the value of Money, we get:
Money = Work / Knowledge
Thus, it is clear from the above equation that as Knowledge approaches
zero, Money approaches infinity, regardless of the amount of work done.
Conclusion: The less you know, the more you make.
Camping with Sherlock Holmes !
Sherlock Holmes and DR Watson went on a camping trip.
After a good meal and a bottle of wine they lay down for the night, and went to
sleep. Some hours later, Holmes awoke and nudged his faithful friend.
"Watson, look up at the sky and tell me what you see."
Watson replied, "I see millions and millions of stars."
"What does that tell you?"
Watson pondered for a minute.
"Astronomically, it tells me that there are
millions of galaxies and potentially billions of
planets.
Astrologically, I observe that Saturn is in Leo.
Horologically, I deduce that the time is approximately a quarter past three.
Theologically, I can see that God is all powerful and that we are small and
insignificant.
Meteorologically, I suspect that we will have a beautiful day tomorrow.
What does it tell you?"
Holmes was silent for a minute, then spoke. "Watson, you idiot. Someone has
stolen our tent."
After a good meal and a bottle of wine they lay down for the night, and went to
sleep. Some hours later, Holmes awoke and nudged his faithful friend.
"Watson, look up at the sky and tell me what you see."
Watson replied, "I see millions and millions of stars."
"What does that tell you?"
Watson pondered for a minute.
"Astronomically, it tells me that there are
millions of galaxies and potentially billions of
planets.
Astrologically, I observe that Saturn is in Leo.
Horologically, I deduce that the time is approximately a quarter past three.
Theologically, I can see that God is all powerful and that we are small and
insignificant.
Meteorologically, I suspect that we will have a beautiful day tomorrow.
What does it tell you?"
Holmes was silent for a minute, then spoke. "Watson, you idiot. Someone has
stolen our tent."
Java Terminilogy ??
Hi,
> Check out these java terms that can be asked in interviews.
>
> > Transcript of an interview(technical) in java:
> > Q. What is the diffrence between an Abstract class and
> Interface?
> > A. terms are different nothing more
> >
> > Q. What do you know about the garbage collector ?
> > A. person who clean the dust bin.
> >
> > Q. Explain RMI Architecture?
> > A. I am a computer professional not an architect student.
> >
> > Q. How do you communicate in between Applets & Servlets ?
> > A. If they are reachable by walk ,I will go in person,else I
> will use
> > phone.
> >
> > Q. What is the use of Servlets ?
> > A. In hotels ,they can replace servers
> >
> > Q. What is the difference between Process and Threads ?
> > A. Threads are small ropes.Make a rope from threads is an
> example for
> > process
> >
> > Q. What is the order of method invocation in an Applet ?
> > A. Either ascending or desending.
> >
> > Q. When is update method called ?
> > A. Who is update method?
> >
> > Q. Have you ever used HashTable and Dictionary ?
> > A. There is a Dictionary named Hash in my table.
> >
> > Q. What is JAR file ?
> > A. file that can be kept inside a jar.
> >
> > Q. What is JINI ?
> > A. A ghost which was Aladdin's friend.
> >
> > Q. What is the base class for all swing components ?
> > A. A glass that can be beneath all and which is very rigid.
> >
> > Q. What is JFC ?
> > A. Jilebi,Fanta&Coffee
> >
> > Q. What is Difference between AWT and Swing ?
> > A. AWT is an acronym .Swing is a word.
> >
> > Q. How will you call an Applet from a Java Script?
> > A. I will give invitation.
> >
> > Q. Why do you Canvas ?
> > A. To get victory in election.
> >
> > Q. How you can know about drivers and database information ?
> > A. I will go and enquire in the bus depot.
> >
> > Q. What is serialization ?
> > A. Arranging one after ther other from left to right.
> >
> > Q. What is bean ? Where it can be used ?
> > A. A kind of vegetable. In kitchens for cooking they can be
> used.
> >
> > Q. How to communicate 2 threads each other ?
> > A. Non living things cann't communicate.
> >
> > Q. Can I modify an object in CORBA ?
> > A. As you wish ,I do not have any objections.
> >
> > Q. What are virtual functions ?
> > A. Functions about which we are dreaming.
> >
> > Q. Write down how will you create a binary Tree ?
> > A. When we sow a binary seed,a binary tree will grow.
> >
> > Q. What is the exact difference in between Unicast and Multicast
>
> > object?
> > A. If in a society ,if there is only one caste ,then it is
> > Unicast,Else it is multicast.
> >
> > Q. I want to store more than 10 objects in a remote server?Which
>
> > methodology will follow ?
> > A. Send it through courier.
> >
> > Q. What is meant by flickering ?
> > A. Closing and opening of eyes at girls.
> >
> > Q. What is meant by distributed Application ?
> > A. Distributing application forms
> >
> > Q. Explain 2 tier and 3 -tier Architecture ?
> > A. Two wheelers like scooters will have 2 tyres and
> autorickshaws will
> > have 3 tyres.
>
>
> Check out these java terms that can be asked in interviews.
>
> > Transcript of an interview(technical) in java:
> > Q. What is the diffrence between an Abstract class and
> Interface?
> > A. terms are different nothing more
> >
> > Q. What do you know about the garbage collector ?
> > A. person who clean the dust bin.
> >
> > Q. Explain RMI Architecture?
> > A. I am a computer professional not an architect student.
> >
> > Q. How do you communicate in between Applets & Servlets ?
> > A. If they are reachable by walk ,I will go in person,else I
> will use
> > phone.
> >
> > Q. What is the use of Servlets ?
> > A. In hotels ,they can replace servers
> >
> > Q. What is the difference between Process and Threads ?
> > A. Threads are small ropes.Make a rope from threads is an
> example for
> > process
> >
> > Q. What is the order of method invocation in an Applet ?
> > A. Either ascending or desending.
> >
> > Q. When is update method called ?
> > A. Who is update method?
> >
> > Q. Have you ever used HashTable and Dictionary ?
> > A. There is a Dictionary named Hash in my table.
> >
> > Q. What is JAR file ?
> > A. file that can be kept inside a jar.
> >
> > Q. What is JINI ?
> > A. A ghost which was Aladdin's friend.
> >
> > Q. What is the base class for all swing components ?
> > A. A glass that can be beneath all and which is very rigid.
> >
> > Q. What is JFC ?
> > A. Jilebi,Fanta&Coffee
> >
> > Q. What is Difference between AWT and Swing ?
> > A. AWT is an acronym .Swing is a word.
> >
> > Q. How will you call an Applet from a Java Script?
> > A. I will give invitation.
> >
> > Q. Why do you Canvas ?
> > A. To get victory in election.
> >
> > Q. How you can know about drivers and database information ?
> > A. I will go and enquire in the bus depot.
> >
> > Q. What is serialization ?
> > A. Arranging one after ther other from left to right.
> >
> > Q. What is bean ? Where it can be used ?
> > A. A kind of vegetable. In kitchens for cooking they can be
> used.
> >
> > Q. How to communicate 2 threads each other ?
> > A. Non living things cann't communicate.
> >
> > Q. Can I modify an object in CORBA ?
> > A. As you wish ,I do not have any objections.
> >
> > Q. What are virtual functions ?
> > A. Functions about which we are dreaming.
> >
> > Q. Write down how will you create a binary Tree ?
> > A. When we sow a binary seed,a binary tree will grow.
> >
> > Q. What is the exact difference in between Unicast and Multicast
>
> > object?
> > A. If in a society ,if there is only one caste ,then it is
> > Unicast,Else it is multicast.
> >
> > Q. I want to store more than 10 objects in a remote server?Which
>
> > methodology will follow ?
> > A. Send it through courier.
> >
> > Q. What is meant by flickering ?
> > A. Closing and opening of eyes at girls.
> >
> > Q. What is meant by distributed Application ?
> > A. Distributing application forms
> >
> > Q. Explain 2 tier and 3 -tier Architecture ?
> > A. Two wheelers like scooters will have 2 tyres and
> autorickshaws will
> > have 3 tyres.
>
>
Fill that space _____
Fill the blanks with one seven letter word. In the second and third
set of blanks the word is split to make sense. It seems this was
asked in the psycho analytic test conducted by Oberoi group of hotels
during recruitment.
A _______ doctor was ___ ____ to perform an operation
because there was __ _____.
set of blanks the word is split to make sense. It seems this was
asked in the psycho analytic test conducted by Oberoi group of hotels
during recruitment.
A _______ doctor was ___ ____ to perform an operation
because there was __ _____.
Saturday, October 9, 2010
The Mathematical Theorems !
Theorem 1. => 3=4.
Proof =>
Suppose a + b = c.
i. e. (4a - 3a) + (4b - 3b) = (4c - 3c)
i. e. 4a + 4b - 4c = 3a + 3b - 3c [ After reorganising ]
i. e. 4*(a+b-c) = 3*(a+b-c) [ Taking constants out of brackets ]
i. e. 4 = 3
Hence the proof.
Theorem 2. => All numbers are equal to zero.
Proof =>
Suppose a = b.
Let sqr = square.
Let sqrt = square root of.
As a = b,
therefore ( a sqr 2 ) = ab
i. e. ( a sqr 2 ) - ( b sqr 2 ) = ab - ( b sqr 2 )
i. e. ( a + b ) * ( a - b ) = b*( a - b )
i. e. a + b = b
i. e. a = 0 ( zero )
Hence the proof.
Theorem 3. => 1$(dollor) = 1c(cent)
Proof =>
And another that gives you a sense of money disappearing...
1$ = 100c
= (10c) sqr 2
= (0.1$) sqr 2
= 0.01$
1$ = 1c
Hence the proof.
Theorem 4. => 1 = -1.
Proof =>
We know 1 = 1.
1 -1
i. e. -- = --
-1 1
_____ _____
[ / 1 ] [ / -1 ]
i.e. [ / -- ] sqr = [ / -- ] sqr
[ \/ -1 ] [ \/ 1 ]
___ _____
( \/ 1 ) sqr ( \/ -1 ) sqr
i.e. ------------- = --------------
____ ____
( \/ -1 ) sqr ( \/ 1 ) sqr
___ ___ ____ ____
i. e. [ ( \/ 1 ) sqr ] * [ ( \/ 1 ) sqr ] = [ ( \/ -1 ) sqr ] * [ ( \/ -1 ) sqr ]
___ ____
i. e. [ [ ( \/ 1 ) sqr ] sqr ] = [ [ ( \/ -1 ) sqr ] sqr ]
___ ____
i. e. \/ 1 = \/ -1
i. e. 1 = -1 [ Squaring both the sides ]
Hence the proof.
Theorem 5. => 4=5.
Proof =>
We know -20 = -20
i. e. 16 - 36 = 25 - 45
i. e. ( 4 sqr 2 ) - ( 9 * 4 ) = ( 5 sqr 2 ) - ( 9 * 5 )
Now add the term (81/4) on both of the sides.
i. e. ( 4 sqr 2 )-( 9 * 4 )+( 81/4 ) = ( 5 sqr 2 )-( 9 * 5 )+( 81/4 )
i. e. ( 4 - ( 9/2 ) ) sqr = ( 5 - ( 9/2 ) ) sqr
i. e. ( 4 - ( 9/2 ) ) = ( 5 - ( 9/2 ) )
i. e. 4 = 5.
Hence the proof.
Theorem 6. => A cat has nine tails.
Proof =>
No cat has eight tails. But a cat has one tail more than no cat.
Therefore a cat has nine tails.
Hence the proof.
Theorem 7. => sin x = 6n.
Proof =>
To prove that sinx = 6n
sinx
i.e. to prove that ------ = 6
n
Canceling n from upper & lower sides, we get
six = 6
which is always true.
Hence the proof.
______________________________________________________________________
" In theory, there is no difference between theory and practicle. But in practice there is."
Proof =>
Suppose a + b = c.
i. e. (4a - 3a) + (4b - 3b) = (4c - 3c)
i. e. 4a + 4b - 4c = 3a + 3b - 3c [ After reorganising ]
i. e. 4*(a+b-c) = 3*(a+b-c) [ Taking constants out of brackets ]
i. e. 4 = 3
Hence the proof.
Theorem 2. => All numbers are equal to zero.
Proof =>
Suppose a = b.
Let sqr = square.
Let sqrt = square root of.
As a = b,
therefore ( a sqr 2 ) = ab
i. e. ( a sqr 2 ) - ( b sqr 2 ) = ab - ( b sqr 2 )
i. e. ( a + b ) * ( a - b ) = b*( a - b )
i. e. a + b = b
i. e. a = 0 ( zero )
Hence the proof.
Theorem 3. => 1$(dollor) = 1c(cent)
Proof =>
And another that gives you a sense of money disappearing...
1$ = 100c
= (10c) sqr 2
= (0.1$) sqr 2
= 0.01$
1$ = 1c
Hence the proof.
Theorem 4. => 1 = -1.
Proof =>
We know 1 = 1.
1 -1
i. e. -- = --
-1 1
_____ _____
[ / 1 ] [ / -1 ]
i.e. [ / -- ] sqr = [ / -- ] sqr
[ \/ -1 ] [ \/ 1 ]
___ _____
( \/ 1 ) sqr ( \/ -1 ) sqr
i.e. ------------- = --------------
____ ____
( \/ -1 ) sqr ( \/ 1 ) sqr
___ ___ ____ ____
i. e. [ ( \/ 1 ) sqr ] * [ ( \/ 1 ) sqr ] = [ ( \/ -1 ) sqr ] * [ ( \/ -1 ) sqr ]
___ ____
i. e. [ [ ( \/ 1 ) sqr ] sqr ] = [ [ ( \/ -1 ) sqr ] sqr ]
___ ____
i. e. \/ 1 = \/ -1
i. e. 1 = -1 [ Squaring both the sides ]
Hence the proof.
Theorem 5. => 4=5.
Proof =>
We know -20 = -20
i. e. 16 - 36 = 25 - 45
i. e. ( 4 sqr 2 ) - ( 9 * 4 ) = ( 5 sqr 2 ) - ( 9 * 5 )
Now add the term (81/4) on both of the sides.
i. e. ( 4 sqr 2 )-( 9 * 4 )+( 81/4 ) = ( 5 sqr 2 )-( 9 * 5 )+( 81/4 )
i. e. ( 4 - ( 9/2 ) ) sqr = ( 5 - ( 9/2 ) ) sqr
i. e. ( 4 - ( 9/2 ) ) = ( 5 - ( 9/2 ) )
i. e. 4 = 5.
Hence the proof.
Theorem 6. => A cat has nine tails.
Proof =>
No cat has eight tails. But a cat has one tail more than no cat.
Therefore a cat has nine tails.
Hence the proof.
Theorem 7. => sin x = 6n.
Proof =>
To prove that sinx = 6n
sinx
i.e. to prove that ------ = 6
n
Canceling n from upper & lower sides, we get
six = 6
which is always true.
Hence the proof.
______________________________________________________________________
" In theory, there is no difference between theory and practicle. But in practice there is."
C++ in collaboration with Bollywood songs !
----------------------------------------------------------------
> [Null pointers] : Mera jeevan kora kagaz kora hi reh gaya.
> [class-constructor,destructor] : Aaj phir jeene ki tamanna hai,
aaj phir marne ka irada hai
> [Local variable] :(1) Mein pal do pal ka shayar hu, pal dopal meri kahani
hai, pal do pal meri hasti hai
(2) Jeena yahaan, marna yahaan iske siwa jaana kahan
> [Undeleted pointers] : Maut bhi aati nahi ,jaan bhi jati nahi.
> [Unused variables] : Badi sooni sooni hai zindagi yeh zindagi
> [#include] : Saathi haath badhana ek akela thak jayega milkarbauj uthana
> [infinite loop] :(1) sau saal pehle, mujhe tumse pyaar tha Aaj bhihai,
aur kal bhi rahega
(2) Hum tum, yug yug se ye geet milan ke
gaate rahehain, gaate rahenge hum tum...
> [IF THEN ELSE] : Tum agar mujhko na chaaho to koi baat nahin Magar kisi
aur ko chaahogi to mushkil hogi.
> [RETURN statement] : Aa laut ke aaja mere meet tujhe mere geet bulaate hain
> [Procedure call] : (1) Aaja rey ab mera dil pukaara
(2) Aaja rey, aaja o mere dibar aaja,
dil ki pyaas bujha ja re
> [unknown identifier] yaad kiya dil ne kahan ho tum?
> [hang] :ghunghroo ki tarah bajta hi raha hoon main
> [remote login] : Tumse kuchh kehna hai, gar tumkuch kehne do
> [network busy] : suno - kaho, kaha - suna, kuchh huwa kya? abhee to
nahin...
> [Two Recursive functions calling each other
(or..deadlock)] : Mujhe kuch kehna hein, mujhe bhi kuch kehna hein pehle
tum, pehle tum...
> [extern variable] : hum hein rahee pyaar ke, humse kuch bhee na boliye jo
bhee pyar se mila hum usike ho liye
> [global variables] :(1) tera mera pyar amar, phir kyon mujko lagta hain darr
(2) tu jahan jahan chalega, mera saaya saath hoga
> [struct] : hum saath-saath hain
> [exit] : chhod aaye hum woh galiyaan
> [macros] : khwaab ho tum ya koi hakikat
> [.h & .c combination] : akele hum akele tum, hum tum sang hai to fir kya
gum
> [private] : kisi ke haath na aayegi yeh ladki
> [zombie & orphans processes ] : na jaane kahan dil kho gaya
> [connection time out] : waqt ne kiya kya hasin sitam
> [RPC] : aa chalke tuje main leke chalu ik aise gagan ke tale
> [Logical error] : hum bewafa hargiz na the, par hum wafa kar na sake
> [Runtime errors] : na jaane kahan se aayi hai, na jaane kahan ko jaayegi
> [Warnings] : Maar diya jaye ke chhod diya jaye, bol tre aath kya sulook
kiya jaye
> [Compilation errors] : Are Deewano, mujhe pehchaano, kahan se aaya main
hoon kaun
> [MSDN help] : Hume aur jeene ki chaahat na hoti, agar tum na hote
> [Running for the 1st time] : muddai lakh chahe to kya hota hain, wohi hota
hai jo manzur- e-khuda hota hain.
> [improper code] : thoda hai, thode ki zarurat hai
>[abstaction] : do ekam do, do dooni chaar, chhoti chhoti baaton main bat gaya sansaar
> for static try something like... "tum jab waapas aaoge to mujhe wahin
paaoge."
// for const try... "chahe kuchh bhi ho jaaye, hum kabhi nahin badalenge"
................................................................................................................................
> [Null pointers] : Mera jeevan kora kagaz kora hi reh gaya.
> [class-constructor,destructor] : Aaj phir jeene ki tamanna hai,
aaj phir marne ka irada hai
> [Local variable] :(1) Mein pal do pal ka shayar hu, pal dopal meri kahani
hai, pal do pal meri hasti hai
(2) Jeena yahaan, marna yahaan iske siwa jaana kahan
> [Undeleted pointers] : Maut bhi aati nahi ,jaan bhi jati nahi.
> [Unused variables] : Badi sooni sooni hai zindagi yeh zindagi
> [#include] : Saathi haath badhana ek akela thak jayega milkarbauj uthana
> [infinite loop] :(1) sau saal pehle, mujhe tumse pyaar tha Aaj bhihai,
aur kal bhi rahega
(2) Hum tum, yug yug se ye geet milan ke
gaate rahehain, gaate rahenge hum tum...
> [IF THEN ELSE] : Tum agar mujhko na chaaho to koi baat nahin Magar kisi
aur ko chaahogi to mushkil hogi.
> [RETURN statement] : Aa laut ke aaja mere meet tujhe mere geet bulaate hain
> [Procedure call] : (1) Aaja rey ab mera dil pukaara
(2) Aaja rey, aaja o mere dibar aaja,
dil ki pyaas bujha ja re
> [unknown identifier] yaad kiya dil ne kahan ho tum?
> [hang] :ghunghroo ki tarah bajta hi raha hoon main
> [remote login] : Tumse kuchh kehna hai, gar tumkuch kehne do
> [network busy] : suno - kaho, kaha - suna, kuchh huwa kya? abhee to
nahin...
> [Two Recursive functions calling each other
(or..deadlock)] : Mujhe kuch kehna hein, mujhe bhi kuch kehna hein pehle
tum, pehle tum...
> [extern variable] : hum hein rahee pyaar ke, humse kuch bhee na boliye jo
bhee pyar se mila hum usike ho liye
> [global variables] :(1) tera mera pyar amar, phir kyon mujko lagta hain darr
(2) tu jahan jahan chalega, mera saaya saath hoga
> [struct] : hum saath-saath hain
> [exit] : chhod aaye hum woh galiyaan
> [macros] : khwaab ho tum ya koi hakikat
> [.h & .c combination] : akele hum akele tum, hum tum sang hai to fir kya
gum
> [private] : kisi ke haath na aayegi yeh ladki
> [zombie & orphans processes ] : na jaane kahan dil kho gaya
> [connection time out] : waqt ne kiya kya hasin sitam
> [RPC] : aa chalke tuje main leke chalu ik aise gagan ke tale
> [Logical error] : hum bewafa hargiz na the, par hum wafa kar na sake
> [Runtime errors] : na jaane kahan se aayi hai, na jaane kahan ko jaayegi
> [Warnings] : Maar diya jaye ke chhod diya jaye, bol tre aath kya sulook
kiya jaye
> [Compilation errors] : Are Deewano, mujhe pehchaano, kahan se aaya main
hoon kaun
> [MSDN help] : Hume aur jeene ki chaahat na hoti, agar tum na hote
> [Running for the 1st time] : muddai lakh chahe to kya hota hain, wohi hota
hai jo manzur- e-khuda hota hain.
> [improper code] : thoda hai, thode ki zarurat hai
>[abstaction] : do ekam do, do dooni chaar, chhoti chhoti baaton main bat gaya sansaar
> for static try something like... "tum jab waapas aaoge to mujhe wahin
paaoge."
// for const try... "chahe kuchh bhi ho jaaye, hum kabhi nahin badalenge"
................................................................................................................................
Hotel management project in c++
// C++ project on Hotel Management
#include
#include
#include
#include
#include
#include
class menu
{ private : void edit_menu(void) ; void report_menu(void) ; void room_edit_menu(void) ; void customer_edit_menu(void) ;
public : void intro(void) ; void main_menu(void) ; void enter_password(void) ;
} ;
// Class definitions
// Customer class
class customer
{ private : int recordno(int) ; void display_record(int) ; void delete_record(int) ; int roomno ; char name[21] , phone[8] ;
float advance , misc , room_srv ;
public : void checkin (void) ; void checkout (void) ; void modify(void) ;
void deletion(void) ; void display_list(void) ; void display_customer_record(void) ;
} ;
class room
{ private : int recordno(int) ; void display_record(int) ; int roomno ; char roomcode[5] , status ; float tariff ;
public : void add (void) ; void modify(void) ; void deletion(void) ; void display_room_record(void) ;
void display_list(void) ; int room_found( int ) ; void change_status(int,char) ; char room_status(int) ;
float get_data(int) ;
} ;
class account
{ public : void prepare_bill(int, float, char t_name[21], float, float, float) ;
} ;
void menu :: enter_password()
{
clrscr() ; char pass1, pass2, pass3 ; gotoxy(30,12) ; cout<<" Enter the password : " ; pass1=getch() ;
cout<<"*" ; pass2=getch() ; cout<<"*" ; pass3=getch() ;cout<<"*" ; getch(); if (pass1 == 'c' && pass2 == 'p' && pass3 == 'p') { return ; }
clrscr(); gotoxy(30,12) ; cout<<" WRONG PASSWORD " ; gotoxy(30,15); cout<<" Aborting . . . "; gotoxy(2,1) ; getch() ; exit(0) ;
}
void menu :: intro ( void )
{
clrscr() ; gotoxy(30,3) ; cout<<" Welcome to Project" ; gotoxy(30,5) ; cout<<" Hotel Management " ; gotoxy(30,6) ; cout<<" ----- ---------- " ;
gotoxy(15,8) ; cout<<"This project has the facility of maintaining " ; gotoxy(15,9) ; cout<<"records of rooms and customers ." ; gotoxy(15,11) ;
cout<<"This project can hold more than 1,000 room" ; gotoxy(15,12) ; cout<<"records at a time." ; gotoxy(15,14) ; cout<<"This project is very easy to work on & has self" ;
gotoxy(15,15) ; cout<<"explanatory menus." ; gotoxy(15,17) ; cout<<"For the security reasons a password facility is " ; gotoxy(15,18) ; cout<<"also provided with this project." ;
cout<<"\t" ; gotoxy(40,20) ; cout<<"- Code written by Pawan Rama Mali "; gotoxy(20,23) ; cout<<"Press any key to continue... " ; getch() ;
main_menu();
}
void menu :: main_menu(void)
{
char ch ; clrscr(); gotoxy(14,2); cout<<"*********** M . A . I . N - M . E . N . U ***********"; gotoxy(30,5) ; cout<<"1. INTRODUCTION" ;
gotoxy(30,7) ; cout<<"2. CHECK IN" ; gotoxy(30,9) ; cout<<"3. CHECK OUT" ; gotoxy(30,11) ; cout<<"4. CUSTOMER RECORDS" ; gotoxy(30,13) ;
cout<<"5. ROOM RECORDS" ; gotoxy(30,15) ; cout<<"6. EDIT " ; gotoxy(30,17) ; cout<<"7. REPORT" ; gotoxy(30,19) ; cout<<"8. EXIT THE PROGRAM " ;
gotoxy(55,25) ; cout<<" - Pawan Rama Mali - " ; gotoxy(30,21) ; cout<<"Enter your choice : " ; cin>>ch;
getch();
if ( ch == '1' ) intro() ;
else if ( ch == '2' ) { customer c ; c.checkin() ; }
else if ( ch == '3' ) { customer c ; c.checkout() ; }
else if ( ch == '4' ) { customer c ; c.display_customer_record() ; }
else if ( ch == '5' ) { room r ; r.display_room_record() ; }
else if ( ch == '6' ) edit_menu() ;
else if ( ch == '7' ) report_menu() ;
else if ( ch == '8' ) { clrscr(); gotoxy(26,10); cout<<" THANK U FOR USING MY PROJECT "; getch(); gotoxy(32,12);
cout<<" HAVE A NICE DAY " ; getch(); exit(0);
}
}
void menu :: edit_menu(void)
{ char ch=1 ; while(ch==1) { clrscr() ; gotoxy(34,4) ; cout<<" EDIT" ; gotoxy(30,8) ; cout<<"1. ROOM RECORDS" ; gotoxy(30,10) ;
cout<<"2. CUSTOMER RECORDS" ; gotoxy(30,12) ; cout<<"3. BACK" ; gotoxy(30,15) ; cout<<"Enter your choice : " ; cin>>ch; getch() ;
if ( ch == '1' ) room_edit_menu() ; else if ( ch == '2' ) customer_edit_menu() ; else if ( ch == '3' )
main_menu();
}
}
void menu :: room_edit_menu(void)
{ char ch=1 ; while(ch==1) { clrscr() ; gotoxy(34,4); cout<<"EDIT ROOM"; gotoxy(30,8) ; cout<<"1. ADD ROOM RECORDS" ; gotoxy(30,10) ;
cout<<"2. MODIFY ROOM RECORDS" ; gotoxy(30,12) ; cout<<"3. DELETE ROOM RECORDS" ; gotoxy(30,14) ; cout<<"4. BACK" ; gotoxy(30,17) ;
cout<<"Enter your choice : " ; cin>>ch; getch() ;
if ( ch == '1' ) { room r ; r.add() ; }
else if ( ch == '2' ) { room r ; r. modify() ; }
else if ( ch == '3' ) { room r ; r.deletion() ; }
else if ( ch == '4' ) break ; }
}
void menu :: customer_edit_menu(void)
{
char ch=1 ;
while(ch==1) { clrscr() ; gotoxy(34,4); cout<<"EDIT CUSTOMER"; gotoxy(30,8) ; cout<<"1. MODIFY CUSTOMER RECORDS" ; gotoxy(30,10) ;
cout<<"2. DELETE CUSTOMER RECORDS" ; gotoxy(30,12) ; cout<<"3. BACK" ; gotoxy(30,15) ; cout<<"Enter your choice : " ; cin>>ch;
getch() ; if ( ch == '1' ) { customer c ; c.modify() ; }
else if ( ch == '2' ) { customer c ; c.deletion() ; }
else if ( ch == '3' ) break ; }
}
void menu :: report_menu(void)
{
char ch ; while(1) { clrscr() ; gotoxy(34,4); cout<<"REPORT"; gotoxy(30,8) ; cout<<"1. LIST OF ROOMS" ; gotoxy(30,10) ;
cout<<"2. LIST OF CUSTOMERS" ; gotoxy(30,12) ; cout<<"3. BACK" ; gotoxy(30,15) ; cout<<"Enter your choice : " ; cin>>ch; getch() ;
if ( ch == '1' ) { room r ; r.display_list() ; }
else if ( ch == '2' ) { customer c ;c.display_list() ;}
else if ( ch == '3' ){ main_menu(); break ;}
}
}
void room :: display_list (void)
{
clrscr() ; fstream file ; file.open("ROOM.DAT", ios::in) ; file.seekg(0) ;
int row = 5 , found = 0 , pageno = 1 ; gotoxy(18,1) ; cout<<"LIST OF ROOMS" ; gotoxy(1,3) ;
cout<<" Room code Room no. Status Tariff " ;
while (file.read((char *) this, sizeof(room)))
{ found = 1 ;
gotoxy(2,row) ;
cout< gotoxy(16,row) ;
cout < gotoxy(29,row) ;
cout < gotoxy(42,row) ;
cout < if ( row == 23 )
{
row = 5 ;
gotoxy(66,1) ;
cout<<"Page no. : " < pageno++ ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
clrscr() ;
gotoxy(18,1) ;
cout<<"LIST OF ROOMS" ;
gotoxy(1,5) ;
cout<<" Room code Room no. Status Tariff " ;
}
else
row++ ;
}
if ( !found )
{
gotoxy(1,5) ;
cout<<"Records not found" ;
}
gotoxy(66,1) ;
cout<<"Page no. : " < gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
file.close () ;
}
void customer :: checkin(void)
{
room r ;
menu m1;
char ch ;
int valid = 1 ;
int t_roomno , t_no_cust ;
char t_name[21] , t_address[35] , t_phone[12] , t_nation[16] , t_passport[30] ;
float t_advance , t_misc , t_room_srv ;
clrscr() ;
gotoxy(1,1) ;
cout<<"Enter the details of the Customer" ;
gotoxy(1,3) ;
cout<<"Room no. : " ;
gotoxy(1,4) ;
cout<<"Name : " ;
gotoxy(1,5) ;
cout<<"No. of guests : " ;
gotoxy(1,6) ;
cout<<"Address : " ;
gotoxy(1,7) ;
cout<<"Phone : " ;
gotoxy(1,8) ;
cout<<"Nationality : " ;
gotoxy(1,9) ;
cout<<"Passport no. : " ;
gotoxy(1,11) ;
cout<<"Advance : " ;
gotoxy(1,12) ;
cout<<"Miscellineous : " ;
gotoxy(1,13) ;
cout<<"Room service : " ;
gotoxy(20,3) ;
cin>>t_roomno ;
char t_status ;
t_status = r.room_status(t_roomno) ;
if (!r.room_found(t_roomno) || t_status == 'O')
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND OR NOT VACANT" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
clrscr();
m1.main_menu() ;
}
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE NAME OF THE CUSTOMER" ;
gotoxy(20,4) ;
gets(t_name) ;
strupr(t_name) ;
fflush(stdin) ;
if ((strlen(t_name) <= 0) || (strlen(t_name) > 20))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT BE ZERO OR GREATER THAN 20" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,4) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE NO. OF GUESTS WITH THE CUSTOMER" ;
gotoxy(20,5) ;
cin>>t_no_cust ;
if ((t_no_cust < 0) || (t_no_cust > 4))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"GUESTS SHOULD NOT BE LESS THAN 0 OR GREATER THAN 4" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,5) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ADDRESS OF THE CUSTOMER" ;
gotoxy(20,6) ;
gets(t_address) ;
fflush(stdin) ;
if ((strlen(t_address) <= 0) || (strlen(t_address) > 50))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT BE ZERO OR GREATER THAN 50" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,6) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE PHONE NO. OF THE CUSTOMER, ENTER '-' FOR NO PHONE NO." ;
gotoxy(20,7) ;
cin>>t_phone ;
if ((strlen(t_phone) < 8 && strlen(t_phone) > 1) || (strlen(t_phone) > 8))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT LESS THAN 8 OR GREATER THAN 8" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,7) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER NATIONALITY OF THE CUSTOMER" ;
gotoxy(20,8) ;
gets(t_nation) ;
fflush(stdin) ;
if ((strlen(t_nation) <= 0) || (strlen(t_nation) > 15))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT LESS THAN ZERO OR GREATER THAN 15" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,8) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER PASSPORT NO. OF THE CUSTOMER" ;
gotoxy(20,9) ;
gets(t_passport) ;
fflush(stdin) ;
if ((strlen(t_passport) <= 0) || (strlen(t_passport) > 15))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT LESS THAN ZERO OR GREATER THAN 15" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,9) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ADVANCE IN RS. " ;
gotoxy(20,11) ;
cin>>t_advance ;
if (t_advance < 0)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,11) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE MISCELLENIOUS CHARGES" ;
gotoxy(20,12) ;
cin>>t_misc ;
if (t_misc < 0)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,12) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM SERVICE CHARGES" ;
gotoxy(20,13) ;
cin>>t_room_srv ;
getch();
if (t_room_srv < 0)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,13) ; clreol() ;
}
} while ( !valid ) ;
gotoxy(1,15) ;
cout<<"Do you want to save the record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(42,15) ;
cin>>ch;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,15) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'Y')
{
r.change_status(t_roomno,'O') ;
roomno = t_roomno ;
strcpy(name,t_name) ;
strcpy(phone,t_phone) ;
advance = t_advance ;
misc = t_misc ;
room_srv = t_room_srv ;
fstream file ;
file.open("CUSTOMER.DAT", ios::out | ios::app ) ;
file.write((char*) this, sizeof(customer)) ;
file.close() ;
}
m1.main_menu() ;
}
char room :: room_status(int t_roomno)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
int found = 0 ;
char t_status ;
while ( file )
{ file.read((char *)this, sizeof(room));
if (t_roomno == roomno)
{
found = 1 ;
t_status = 'O';
}
}
file.close () ;
return t_status ;
}
int room :: room_found ( int t_roomno )
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
int found = 0 ;
while (file.read((char *) this, sizeof(room)))
{
if ( roomno == t_roomno )
found = 1 ;
}
file.close() ;
return found ;
}
int room :: recordno(int t_roomno)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
int count = 0 ;
while (file.read((char *) this, sizeof(room)))
{
count++ ;
if (t_roomno == roomno)
break ;
}
file.close() ;
return count ;
}
void room :: display_record(int t_roomno)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
int found = 0 ;
while (file.read((char *) this, sizeof(room)) && !found)
{
if (t_roomno == roomno)
{
found = 1 ;
gotoxy(1,5) ;
cout<<"Room code : " < gotoxy(1,6) ;
cout<<"Room no. : " < gotoxy(1,7) ;
cout<<"Status : " < gotoxy(1,8) ;
cout<<"Tariff : " < }
}
file.close () ;
}
void room :: display_room_record(void)
{
clrscr() ;
menu m;
int valid ;
int t_roomno ;
gotoxy(1,3) ;
cout<<"Enter the Room no. : " ;
cin>>t_roomno ;
if (!room_found(t_roomno))
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
m.main_menu();
}
clrscr() ;
gotoxy(5,3) ;
cout<<"ROOM RECORD" ;
display_record(t_roomno) ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
m.main_menu();
}
void room :: change_status(int t_roomno , char t_status)
{
int recno ;
recno = recordno(t_roomno) ;
fstream file ;
file.open("ROOM.DAT", ios::out | ios::ate) ;
int location ;
location = (recno-1) * sizeof(room) ;
file.seekp(location) ;
status = t_status ;
file.write((char *) this, sizeof(room)) ;
file.close () ;
}
float room :: get_data(int t_roomno)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
float t_tariff ;
while (file.read((char *) this, sizeof(room)))
{
if (t_roomno == roomno)
{
t_tariff = tariff ;
break ;
}
}
file.close() ;
return t_tariff ;
}
void room :: add (void)
{
char ch ;
char t_rcode[5] ;
int t_roomno ;
char t_status ;
float t_tariff ;
do
{
fstream file ;
file.open("ROOM.DAT", ios::out | ios::app ) ;
clrscr() ;
gotoxy(1,1) ;
cout<<"Enter the details for the room" ;
gotoxy(1,3) ;
cout<<"Code : " ;
gotoxy(1,4) ;
cout<<"Room no. : " ;
gotoxy(1,5) ;
cout<<"Status : " ;
gotoxy(1,6) ;
cout<<"Tariff : " ;
gotoxy(20,11) ;
cout<<"SS : SINGLE SUIT" ;
gotoxy(20,12) ;
cout<<"SR : SINGLE ROOM" ;
gotoxy(20,13) ;
cout<<"DR : DOUBLE ROOM" ;
gotoxy(20,14) ;
cout<<"DS : DOUBLE SUIT" ;
int valid = 0 ;
do
{
valid = 1 ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM CODE (SS/SR/DR/DS)" ;
gotoxy(13,3) ;
cin>>t_rcode ;
strupr(t_rcode) ;
char *string[4] = {"SS","DR","SR","DS"} ;
int result , count = 0 ;
for ( int i=0; i<4; i++ )
{
result = strcmpi(t_rcode,string[i]) ;
if ( result != 0 )
count++ ;
}
if ( count == 4 )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"INVALID CODE" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,3) ; clreol() ;
}
} while ( valid == 0 ) ;
for ( int i=11; i<=14; i++ )
{
gotoxy(1,i) ; clreol() ;
}
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM NUMBER" ;
gotoxy(13,4) ;
cin>>t_roomno ;
getch();
if ( t_roomno <= 0 || t_roomno > 900 )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"IT SHOULD NOT BE NEGATIVE OR ZERO OR GREATER THAN 900" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,4) ; clreol() ;
}
if ( room_found( t_roomno ) )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. ALREADY EXIST" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,4) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM STATUS : V=vacant, O=occupied" ;
gotoxy(13,5) ;
cin>>t_status ;
t_status = toupper(t_status) ;
if (t_status != 'O' && t_status != 'V')
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"INVALID DATA ENTERED" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,5) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE TARIFF FOR THE ROOM" ;
gotoxy(13,6) ;
cin>>t_tariff ;
getch();
if ( t_tariff <= 0 )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"IT SHOULD NOT BE NEGATIVE OR ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,6) ; clreol() ;
}
} while ( !valid ) ;
gotoxy(1,8) ;
cout<<"Do you want to save the record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(42,8) ;
cin>>ch;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,8) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'Y')
{
strcpy(roomcode,t_rcode) ;
roomno = t_roomno ;
status = t_status ;
tariff = t_tariff ;
file.write((char *) this, sizeof(room)) ;
}
gotoxy(1,9) ;
cout<<"Do you want to add more records (y/n) : " ;
do
{
valid = 1 ;
gotoxy(42,9) ;
cin>>ch;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,9) ; clreol() ;
}
} while ( !valid ) ;
file.close () ;
} while ( ch == 'Y') ;
}
void room :: modify(void)
{
clrscr() ;
int valid ;
char ch ;
char t_rcode[5] ;
int t_roomno , tr ;
char t_status ;
float t_tariff ;
fstream file ;
file.open("ROOM.DAT", ios::out | ios::ate) ;
gotoxy(1,3) ;
cout<<"Enter the Room no. to be modified " ;
cin>>tr ;
getch();
if ( !room_found( tr ) )
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
return ;
}
display_record(tr) ;
gotoxy(1,10) ;
cout<<"Do you want to modify this Room Record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(48,10) ;
cin>>ch;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,9) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'N')
return ;
gotoxy(1,12) ;
cout<<"ENTER THE NEW DATA FOR THE ROOM" ;
gotoxy(1,14) ;
cout<<"Code : " ;
gotoxy(1,15) ;
cout<<"Room no. : " ;
gotoxy(1,16) ;
cout<<"Status : " ;
gotoxy(1,17) ;
cout<<"Tariff : " ;
do
{
valid = 1 ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM CODE (SS/SR/DR/DS)" ;
gotoxy(13,14) ;
cin>>t_rcode ;
getch();
strupr(t_rcode) ;
char *string[4] = {"SS","DR","SR","DS"} ;
int result , count = 0 ;
for ( int i=0; i<4; i++ )
{
result = strcmpi(t_rcode,string[i]) ;
if ( result != 0 )
count++ ;
}
if ( count == 4 )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"INVALID CODE" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,14) ; clreol() ;
}
} while ( valid == 0 ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM NUMBER" ;
gotoxy(13,15) ;
cin>>t_roomno ;
getch();
if ( t_roomno <= 0 || t_roomno > 900 )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"IT SHOULD NOT BE NEGATIVE OR ZERO OR GREATER THAN 900" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,15) ; clreol() ;
}
if ( room_found( t_roomno ) && t_roomno != tr )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. ALREADY EXIST" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,15) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM STATUS : V=vacant, O=occupied" ;
gotoxy(13,16) ;
cin>>t_status ;
getch();
t_status = toupper(t_status) ;
if (t_status != 'O' && t_status != 'V')
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"INVALID DATA ENTERED" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,16) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE TARIFF FOR THE ROOM" ;
gotoxy(13,17) ;
cin>>t_tariff ;
getch();
if ( t_tariff <= 0 )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"IT SHOULD NOT BE NEGATIVE OR ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,17) ; clreol() ;
}
} while ( !valid ) ;
gotoxy(1,19) ;
cout<<"Do you want to save the record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(42,19) ;
ch = getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,19) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'Y')
{
int recno ;
recno = recordno(tr) ;
int location ;
location = (recno-1) * sizeof(room) ;
file.seekp(location) ;
strcpy(roomcode,t_rcode) ;
roomno = t_roomno ;
status = t_status ;
tariff = t_tariff ;
file.write((char *) this, sizeof(room)) ;
}
file.close () ;
}
void room :: deletion(void)
{
clrscr() ;
int valid ;
char ch ;
int t_roomno ;
gotoxy(1,3) ;
cout<<"Enter the Room no. to be deleted " ;
cin>>t_roomno ;
if ( !room_found( t_roomno ) )
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
return ;
}
display_record(t_roomno) ;
gotoxy(1,10) ;
cout<<"Do you want to delete this Room Record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(48,10) ;
cin>>ch ;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,9) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'N')
return ;
fstream file ;
file.open("ROOM.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(room)) ;
if ( file.eof() )
break ;
if ( roomno != t_roomno )
temp.write((char *) this, sizeof(room)) ;
}
file.close() ;
temp.close() ;
file.open("ROOM.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(room)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(room)) ;
}
file.close() ;
temp.close() ;
}
void customer :: display_list(void)
{
clrscr() ;
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0) ;
int row = 5 ;
int found = 0 ;
int pageno = 1 ;
int total = 0 ;
gotoxy(18,1) ;
cout<<"LIST OF CUSTOMERS" ;
gotoxy(1,3) ;
cout<<" Room no. Name Phone Room service Advance Misc." ;
while (file.read((char *) this, sizeof(customer)))
{
total++ ;
found = 1 ;
gotoxy(2,row) ;
cout< gotoxy(12,row) ;
puts(name) ;
fflush(stdout) ;
gotoxy(34,row) ;
cout< gotoxy(47,row) ;
cout< gotoxy(62,row) ;
cout< gotoxy(72,row) ;
cout< if ( row == 23 )
{
row = 5 ;
gotoxy(66,1) ;
cout<<"Page no. : " < pageno++ ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
clrscr() ;
gotoxy(18,1) ;
cout<<"LIST OF CUSTOMERS" ;
gotoxy(1,3) ;
cout<<" Room no. Name Phone Room service Advance Misc." ;
}
else
row++ ;
}
if ( found==0 )
{
gotoxy(1,5) ;
cout<<"Records not found" ;
}
gotoxy(66,1) ;
cout<<"Page no. : " < gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
clrscr() ;
gotoxy(5,5) ;
cout<<"Total no. of Customers = " < gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
file.close () ;
}
void customer :: display_record(int t_roomno)
{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0) ;
int found = 0 ;
while (file.read((char *) this, sizeof(customer)) && !found)
{
if (t_roomno == roomno)
{
found = 1 ;
gotoxy(1,5) ;
cout<<"Room no. : " < gotoxy(1,6) ;
cout<<"Customer Name : " < gotoxy(1,7) ;
cout<<"Phone no. : " < gotoxy(1,8) ;
cout<<"Advance : " < gotoxy(1,9) ;
cout<<"Misc. charges : " < gotoxy(1,10) ;
cout<<"Room Service Charges : " < }
}
file.close () ;
}
int customer :: recordno(int t_roomno)
{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0) ;
int count = 0 ;
while (file.read((char *) this, sizeof(customer)))
{
count++ ;
if (t_roomno == roomno)
break ;
}
file.close() ;
return count ;
}
void customer :: modify(void)
{
clrscr() ;
room r ;
int valid ;
char ch ;
int t_roomno , tr ;
char t_name[21] , t_phone[8] ;
float t_advance , t_misc , t_room_srv ;
fstream file ;
file.open("CUSTOMER.DAT", ios::out | ios::ate) ;
gotoxy(1,3) ;
cout<<"Enter the Room no. of the customer to be modified " ;
cin>>tr ;
getch();
char t_status ;
t_status = r.room_status(tr) ;
if (!r.room_found(tr) || t_status == 'V')
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND OR ROOM IS VACANT" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
return ;
}
display_record(tr) ;
gotoxy(1,12) ;
cout<<"Do you want to modify this Room Record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(48,12) ;
cin>>ch;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,12) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'N')
return ;
gotoxy(1,14) ;
cout<<"ENTER THE NEW DATA FOR THE CUSTOMER" ;
gotoxy(1,16) ;
cout<<"Room no. : " ;
gotoxy(1,17) ;
cout<<"Name : " ;
gotoxy(1,18) ;
cout<<"Phone : " ;
gotoxy(1,19) ;
cout<<"Advance : " ;
gotoxy(1,20) ;
cout<<"Miscellineous : " ;
gotoxy(1,21) ;
cout<<"Room service : " ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM NUMBER FOR CUSTOMER : " ;
gotoxy(20,16) ;
cin>>t_roomno ;
getch();
t_status = r.room_status(t_roomno) ;
if ((!r.room_found(t_roomno)) || (r.room_found(t_roomno) && t_roomno != tr && t_status == 'O'))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT EXIST OR NOT VACANT" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,16) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE NAME OF THE CUSTOMER : " ;
gotoxy(20,17) ;
gets(t_name) ;
getch();
strupr(t_name) ;
fflush(stdin) ;
if ((strlen(t_name) <= 0) || (strlen(t_name) > 20))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT BE ZERO OR GREATER THAN 20" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,17) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE PHONE NO. OF THE CUSTOMER, ENTER '-' FOR NO PHONE NO." ;
gotoxy(20,18) ;
cin>>t_phone ;
if ((strlen(t_phone) < 8 && strlen(t_phone) > 1) || (strlen(t_phone) > 8))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT LESS THAN 8 OR GREATER THAN 8" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,18) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ADVANCE RS. " ;
gotoxy(20,19) ;
cin>>t_advance ;
getch();
if (t_advance < 0)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,19) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE MISCALLENIOUS CHARGES" ;
gotoxy(20,20) ;
cin>>t_misc ;
getch();
if (t_misc < 0)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,20) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM SERVICE CHARGES" ;
gotoxy(20,21) ;
cin>>t_room_srv ;
getch();
if (t_room_srv < 0)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,21) ; clreol() ;
}
} while ( !valid ) ;
gotoxy(1,23) ;
cout<<"Do you want to save the record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(42,23) ;
cin>>ch;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,23) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'Y')
{
if (t_roomno != tr)
{
r.change_status(t_roomno,'O') ;
r.change_status(tr,'V') ;
}
int recno ;
recno = recordno(tr) ;
int location ;
location = (recno-1) * sizeof(customer) ;
file.seekp(location) ;
roomno = t_roomno ;
strcpy(name,t_name) ;
strcpy(phone,t_phone) ;
room_srv = t_room_srv ;
advance = t_advance ;
misc = t_misc ;
file.write((char *) this, sizeof(customer)) ;
}
file.close () ;
}
void customer :: delete_record(int t_roomno)
{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(customer)) ;
if ( file.eof() )
break ;
if ( roomno != t_roomno )
temp.write((char *) this, sizeof(customer)) ;
}
file.close() ;
temp.close() ;
file.open("CUSTOMER.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(customer)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(customer)) ;
}
file.close() ;
temp.close() ;
}
void customer :: display_customer_record(void)
{
clrscr() ;
room r ;
int valid ;
int t_roomno ;
gotoxy(1,3) ;
cout<<"Enter the Room no. of the customer : " ;
cin>>t_roomno ;
char t_status ;
t_status = r.room_status(t_roomno) ;
if (!r.room_found(t_roomno) || t_status == 'V')
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND OR ROOM IS VACANT" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
return ;
}
clrscr() ;
gotoxy(5,3) ;
cout<<"CUSTOMER RECORD" ;
display_record(t_roomno) ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
}
void customer :: deletion(void)
{
clrscr() ;
room r ;
int valid ;
char ch ;
int t_roomno ;
gotoxy(1,3) ;
cout<<"Enter the Room no. of the customer to be deleted " ;
cin>>t_roomno ;
char t_status ;
t_status = r.room_status(t_roomno) ;
if (!r.room_found(t_roomno) || t_status == 'V')
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND OR ROOM IS VACANT" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
return ;
}
display_record(t_roomno) ;
gotoxy(1,15) ;
cout<<"Do you want to delete this Customer Record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(52,15) ;
cin>>ch ;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(52,15) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'N')
return ;
r.change_status(t_roomno,'V') ;
delete_record(t_roomno) ;
}
void customer :: checkout(void)
{
clrscr() ;
menu m1 ;
room r ;
int valid ;
char ch ;
int t_roomno ;
gotoxy(1,3) ;
cout<<"Enter the Room no. of the customer to be check out " ;
cin>>t_roomno ;
char t_status ;
t_status = r.room_status(t_roomno) ;
if (!r.room_found(t_roomno) || t_status == 'V')
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND OR ROOM IS VACANT" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
m1.main_menu();
}
display_record(t_roomno) ;
gotoxy(1,15) ;
cout<<"Do you want to prepare bill of this Customer Record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(63,15) ;
cin>>ch;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(63,15) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'N')
return ;
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0) ;
char t_name[21] ;
float t_advance, t_room_srv, t_misc, t_tariff ;
while (file.read((char *) this, sizeof(customer)))
{
if (t_roomno == roomno)
{
strcpy(t_name,name) ;
t_advance = advance ;
t_room_srv = room_srv ;
t_misc = misc ;
break ;
}
}
file.close() ;
t_tariff = r.get_data(t_roomno) ;
account a ;
a.prepare_bill(t_roomno,t_tariff,t_name,t_advance,t_room_srv,t_misc) ;
r.change_status(t_roomno,'V') ;
delete_record(t_roomno) ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
m1.main_menu() ;
}
void account :: prepare_bill(int t_roomno, float t_tariff, char t_name[21], float t_advance, float t_room_srv, float t_misc)
{
menu m1 ;
int valid ;
int days ;
float tax , total ;
gotoxy(1,17) ;
cout<<"Enter the no. of days : " ;
do
{
valid = 1 ;
gotoxy(25,17) ;
cin>>days ;
if (days < 0 || days > 2000)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(25,17) ; clreol() ;
}
} while ( !valid ) ;
t_tariff = t_tariff * days ;
total = (t_room_srv + t_misc + t_tariff) - t_advance ;
tax = total * 0.22 ;
total = total + tax ;
clrscr() ;
menu m ;
gotoxy(5,3) ;
cout<<"Bill of Room no. : " < gotoxy(5,6) ;
cout<<"Name of Customer : " < gotoxy(5,8) ;
cout<<"Tariff Charges : " < gotoxy(5,10) ;
cout<<"Misc. Charges : " < gotoxy(5,12) ;
cout<<"Room service Charges : " < gotoxy(5,14) ;
cout<<"Tax : " < gotoxy(5,16) ;
cout<<"Advance : " < gotoxy(5,18) ;
cout<<"------------------------------------------" ;
gotoxy(5,19) ;
cout<<"Total Bill : " < gotoxy(5,20) ;
cout<<"------------------------------------------" ;
}
void main()
{
menu m ;
m.enter_password() ;
m.intro();
}
#include
#include
#include
#include
#include
#include
class menu
{ private : void edit_menu(void) ; void report_menu(void) ; void room_edit_menu(void) ; void customer_edit_menu(void) ;
public : void intro(void) ; void main_menu(void) ; void enter_password(void) ;
} ;
// Class definitions
// Customer class
class customer
{ private : int recordno(int) ; void display_record(int) ; void delete_record(int) ; int roomno ; char name[21] , phone[8] ;
float advance , misc , room_srv ;
public : void checkin (void) ; void checkout (void) ; void modify(void) ;
void deletion(void) ; void display_list(void) ; void display_customer_record(void) ;
} ;
class room
{ private : int recordno(int) ; void display_record(int) ; int roomno ; char roomcode[5] , status ; float tariff ;
public : void add (void) ; void modify(void) ; void deletion(void) ; void display_room_record(void) ;
void display_list(void) ; int room_found( int ) ; void change_status(int,char) ; char room_status(int) ;
float get_data(int) ;
} ;
class account
{ public : void prepare_bill(int, float, char t_name[21], float, float, float) ;
} ;
void menu :: enter_password()
{
clrscr() ; char pass1, pass2, pass3 ; gotoxy(30,12) ; cout<<" Enter the password : " ; pass1=getch() ;
cout<<"*" ; pass2=getch() ; cout<<"*" ; pass3=getch() ;cout<<"*" ; getch(); if (pass1 == 'c' && pass2 == 'p' && pass3 == 'p') { return ; }
clrscr(); gotoxy(30,12) ; cout<<" WRONG PASSWORD " ; gotoxy(30,15); cout<<" Aborting . . . "; gotoxy(2,1) ; getch() ; exit(0) ;
}
void menu :: intro ( void )
{
clrscr() ; gotoxy(30,3) ; cout<<" Welcome to Project" ; gotoxy(30,5) ; cout<<" Hotel Management " ; gotoxy(30,6) ; cout<<" ----- ---------- " ;
gotoxy(15,8) ; cout<<"This project has the facility of maintaining " ; gotoxy(15,9) ; cout<<"records of rooms and customers ." ; gotoxy(15,11) ;
cout<<"This project can hold more than 1,000 room" ; gotoxy(15,12) ; cout<<"records at a time." ; gotoxy(15,14) ; cout<<"This project is very easy to work on & has self" ;
gotoxy(15,15) ; cout<<"explanatory menus." ; gotoxy(15,17) ; cout<<"For the security reasons a password facility is " ; gotoxy(15,18) ; cout<<"also provided with this project." ;
cout<<"\t" ; gotoxy(40,20) ; cout<<"- Code written by Pawan Rama Mali "; gotoxy(20,23) ; cout<<"Press any key to continue... " ; getch() ;
main_menu();
}
void menu :: main_menu(void)
{
char ch ; clrscr(); gotoxy(14,2); cout<<"*********** M . A . I . N - M . E . N . U ***********"; gotoxy(30,5) ; cout<<"1. INTRODUCTION" ;
gotoxy(30,7) ; cout<<"2. CHECK IN" ; gotoxy(30,9) ; cout<<"3. CHECK OUT" ; gotoxy(30,11) ; cout<<"4. CUSTOMER RECORDS" ; gotoxy(30,13) ;
cout<<"5. ROOM RECORDS" ; gotoxy(30,15) ; cout<<"6. EDIT " ; gotoxy(30,17) ; cout<<"7. REPORT" ; gotoxy(30,19) ; cout<<"8. EXIT THE PROGRAM " ;
gotoxy(55,25) ; cout<<" - Pawan Rama Mali - " ; gotoxy(30,21) ; cout<<"Enter your choice : " ; cin>>ch;
getch();
if ( ch == '1' ) intro() ;
else if ( ch == '2' ) { customer c ; c.checkin() ; }
else if ( ch == '3' ) { customer c ; c.checkout() ; }
else if ( ch == '4' ) { customer c ; c.display_customer_record() ; }
else if ( ch == '5' ) { room r ; r.display_room_record() ; }
else if ( ch == '6' ) edit_menu() ;
else if ( ch == '7' ) report_menu() ;
else if ( ch == '8' ) { clrscr(); gotoxy(26,10); cout<<" THANK U FOR USING MY PROJECT "; getch(); gotoxy(32,12);
cout<<" HAVE A NICE DAY " ; getch(); exit(0);
}
}
void menu :: edit_menu(void)
{ char ch=1 ; while(ch==1) { clrscr() ; gotoxy(34,4) ; cout<<" EDIT" ; gotoxy(30,8) ; cout<<"1. ROOM RECORDS" ; gotoxy(30,10) ;
cout<<"2. CUSTOMER RECORDS" ; gotoxy(30,12) ; cout<<"3. BACK" ; gotoxy(30,15) ; cout<<"Enter your choice : " ; cin>>ch; getch() ;
if ( ch == '1' ) room_edit_menu() ; else if ( ch == '2' ) customer_edit_menu() ; else if ( ch == '3' )
main_menu();
}
}
void menu :: room_edit_menu(void)
{ char ch=1 ; while(ch==1) { clrscr() ; gotoxy(34,4); cout<<"EDIT ROOM"; gotoxy(30,8) ; cout<<"1. ADD ROOM RECORDS" ; gotoxy(30,10) ;
cout<<"2. MODIFY ROOM RECORDS" ; gotoxy(30,12) ; cout<<"3. DELETE ROOM RECORDS" ; gotoxy(30,14) ; cout<<"4. BACK" ; gotoxy(30,17) ;
cout<<"Enter your choice : " ; cin>>ch; getch() ;
if ( ch == '1' ) { room r ; r.add() ; }
else if ( ch == '2' ) { room r ; r. modify() ; }
else if ( ch == '3' ) { room r ; r.deletion() ; }
else if ( ch == '4' ) break ; }
}
void menu :: customer_edit_menu(void)
{
char ch=1 ;
while(ch==1) { clrscr() ; gotoxy(34,4); cout<<"EDIT CUSTOMER"; gotoxy(30,8) ; cout<<"1. MODIFY CUSTOMER RECORDS" ; gotoxy(30,10) ;
cout<<"2. DELETE CUSTOMER RECORDS" ; gotoxy(30,12) ; cout<<"3. BACK" ; gotoxy(30,15) ; cout<<"Enter your choice : " ; cin>>ch;
getch() ; if ( ch == '1' ) { customer c ; c.modify() ; }
else if ( ch == '2' ) { customer c ; c.deletion() ; }
else if ( ch == '3' ) break ; }
}
void menu :: report_menu(void)
{
char ch ; while(1) { clrscr() ; gotoxy(34,4); cout<<"REPORT"; gotoxy(30,8) ; cout<<"1. LIST OF ROOMS" ; gotoxy(30,10) ;
cout<<"2. LIST OF CUSTOMERS" ; gotoxy(30,12) ; cout<<"3. BACK" ; gotoxy(30,15) ; cout<<"Enter your choice : " ; cin>>ch; getch() ;
if ( ch == '1' ) { room r ; r.display_list() ; }
else if ( ch == '2' ) { customer c ;c.display_list() ;}
else if ( ch == '3' ){ main_menu(); break ;}
}
}
void room :: display_list (void)
{
clrscr() ; fstream file ; file.open("ROOM.DAT", ios::in) ; file.seekg(0) ;
int row = 5 , found = 0 , pageno = 1 ; gotoxy(18,1) ; cout<<"LIST OF ROOMS" ; gotoxy(1,3) ;
cout<<" Room code Room no. Status Tariff " ;
while (file.read((char *) this, sizeof(room)))
{ found = 1 ;
gotoxy(2,row) ;
cout<
cout <
cout <
cout <
{
row = 5 ;
gotoxy(66,1) ;
cout<<"Page no. : " <
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
clrscr() ;
gotoxy(18,1) ;
cout<<"LIST OF ROOMS" ;
gotoxy(1,5) ;
cout<<" Room code Room no. Status Tariff " ;
}
else
row++ ;
}
if ( !found )
{
gotoxy(1,5) ;
cout<<"Records not found" ;
}
gotoxy(66,1) ;
cout<<"Page no. : " <
cout<<"Press any key to continue..." ;
getch() ;
file.close () ;
}
void customer :: checkin(void)
{
room r ;
menu m1;
char ch ;
int valid = 1 ;
int t_roomno , t_no_cust ;
char t_name[21] , t_address[35] , t_phone[12] , t_nation[16] , t_passport[30] ;
float t_advance , t_misc , t_room_srv ;
clrscr() ;
gotoxy(1,1) ;
cout<<"Enter the details of the Customer" ;
gotoxy(1,3) ;
cout<<"Room no. : " ;
gotoxy(1,4) ;
cout<<"Name : " ;
gotoxy(1,5) ;
cout<<"No. of guests : " ;
gotoxy(1,6) ;
cout<<"Address : " ;
gotoxy(1,7) ;
cout<<"Phone : " ;
gotoxy(1,8) ;
cout<<"Nationality : " ;
gotoxy(1,9) ;
cout<<"Passport no. : " ;
gotoxy(1,11) ;
cout<<"Advance : " ;
gotoxy(1,12) ;
cout<<"Miscellineous : " ;
gotoxy(1,13) ;
cout<<"Room service : " ;
gotoxy(20,3) ;
cin>>t_roomno ;
char t_status ;
t_status = r.room_status(t_roomno) ;
if (!r.room_found(t_roomno) || t_status == 'O')
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND OR NOT VACANT" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
clrscr();
m1.main_menu() ;
}
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE NAME OF THE CUSTOMER" ;
gotoxy(20,4) ;
gets(t_name) ;
strupr(t_name) ;
fflush(stdin) ;
if ((strlen(t_name) <= 0) || (strlen(t_name) > 20))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT BE ZERO OR GREATER THAN 20" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,4) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE NO. OF GUESTS WITH THE CUSTOMER" ;
gotoxy(20,5) ;
cin>>t_no_cust ;
if ((t_no_cust < 0) || (t_no_cust > 4))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"GUESTS SHOULD NOT BE LESS THAN 0 OR GREATER THAN 4" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,5) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ADDRESS OF THE CUSTOMER" ;
gotoxy(20,6) ;
gets(t_address) ;
fflush(stdin) ;
if ((strlen(t_address) <= 0) || (strlen(t_address) > 50))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT BE ZERO OR GREATER THAN 50" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,6) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE PHONE NO. OF THE CUSTOMER, ENTER '-' FOR NO PHONE NO." ;
gotoxy(20,7) ;
cin>>t_phone ;
if ((strlen(t_phone) < 8 && strlen(t_phone) > 1) || (strlen(t_phone) > 8))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT LESS THAN 8 OR GREATER THAN 8" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,7) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER NATIONALITY OF THE CUSTOMER" ;
gotoxy(20,8) ;
gets(t_nation) ;
fflush(stdin) ;
if ((strlen(t_nation) <= 0) || (strlen(t_nation) > 15))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT LESS THAN ZERO OR GREATER THAN 15" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,8) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER PASSPORT NO. OF THE CUSTOMER" ;
gotoxy(20,9) ;
gets(t_passport) ;
fflush(stdin) ;
if ((strlen(t_passport) <= 0) || (strlen(t_passport) > 15))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT LESS THAN ZERO OR GREATER THAN 15" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,9) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ADVANCE IN RS. " ;
gotoxy(20,11) ;
cin>>t_advance ;
if (t_advance < 0)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,11) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE MISCELLENIOUS CHARGES" ;
gotoxy(20,12) ;
cin>>t_misc ;
if (t_misc < 0)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,12) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM SERVICE CHARGES" ;
gotoxy(20,13) ;
cin>>t_room_srv ;
getch();
if (t_room_srv < 0)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,13) ; clreol() ;
}
} while ( !valid ) ;
gotoxy(1,15) ;
cout<<"Do you want to save the record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(42,15) ;
cin>>ch;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,15) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'Y')
{
r.change_status(t_roomno,'O') ;
roomno = t_roomno ;
strcpy(name,t_name) ;
strcpy(phone,t_phone) ;
advance = t_advance ;
misc = t_misc ;
room_srv = t_room_srv ;
fstream file ;
file.open("CUSTOMER.DAT", ios::out | ios::app ) ;
file.write((char*) this, sizeof(customer)) ;
file.close() ;
}
m1.main_menu() ;
}
char room :: room_status(int t_roomno)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
int found = 0 ;
char t_status ;
while ( file )
{ file.read((char *)this, sizeof(room));
if (t_roomno == roomno)
{
found = 1 ;
t_status = 'O';
}
}
file.close () ;
return t_status ;
}
int room :: room_found ( int t_roomno )
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
int found = 0 ;
while (file.read((char *) this, sizeof(room)))
{
if ( roomno == t_roomno )
found = 1 ;
}
file.close() ;
return found ;
}
int room :: recordno(int t_roomno)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
int count = 0 ;
while (file.read((char *) this, sizeof(room)))
{
count++ ;
if (t_roomno == roomno)
break ;
}
file.close() ;
return count ;
}
void room :: display_record(int t_roomno)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
int found = 0 ;
while (file.read((char *) this, sizeof(room)) && !found)
{
if (t_roomno == roomno)
{
found = 1 ;
gotoxy(1,5) ;
cout<<"Room code : " <
cout<<"Room no. : " <
cout<<"Status : " <
cout<<"Tariff : " <
}
file.close () ;
}
void room :: display_room_record(void)
{
clrscr() ;
menu m;
int valid ;
int t_roomno ;
gotoxy(1,3) ;
cout<<"Enter the Room no. : " ;
cin>>t_roomno ;
if (!room_found(t_roomno))
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
m.main_menu();
}
clrscr() ;
gotoxy(5,3) ;
cout<<"ROOM RECORD" ;
display_record(t_roomno) ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
m.main_menu();
}
void room :: change_status(int t_roomno , char t_status)
{
int recno ;
recno = recordno(t_roomno) ;
fstream file ;
file.open("ROOM.DAT", ios::out | ios::ate) ;
int location ;
location = (recno-1) * sizeof(room) ;
file.seekp(location) ;
status = t_status ;
file.write((char *) this, sizeof(room)) ;
file.close () ;
}
float room :: get_data(int t_roomno)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
float t_tariff ;
while (file.read((char *) this, sizeof(room)))
{
if (t_roomno == roomno)
{
t_tariff = tariff ;
break ;
}
}
file.close() ;
return t_tariff ;
}
void room :: add (void)
{
char ch ;
char t_rcode[5] ;
int t_roomno ;
char t_status ;
float t_tariff ;
do
{
fstream file ;
file.open("ROOM.DAT", ios::out | ios::app ) ;
clrscr() ;
gotoxy(1,1) ;
cout<<"Enter the details for the room" ;
gotoxy(1,3) ;
cout<<"Code : " ;
gotoxy(1,4) ;
cout<<"Room no. : " ;
gotoxy(1,5) ;
cout<<"Status : " ;
gotoxy(1,6) ;
cout<<"Tariff : " ;
gotoxy(20,11) ;
cout<<"SS : SINGLE SUIT" ;
gotoxy(20,12) ;
cout<<"SR : SINGLE ROOM" ;
gotoxy(20,13) ;
cout<<"DR : DOUBLE ROOM" ;
gotoxy(20,14) ;
cout<<"DS : DOUBLE SUIT" ;
int valid = 0 ;
do
{
valid = 1 ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM CODE (SS/SR/DR/DS)" ;
gotoxy(13,3) ;
cin>>t_rcode ;
strupr(t_rcode) ;
char *string[4] = {"SS","DR","SR","DS"} ;
int result , count = 0 ;
for ( int i=0; i<4; i++ )
{
result = strcmpi(t_rcode,string[i]) ;
if ( result != 0 )
count++ ;
}
if ( count == 4 )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"INVALID CODE" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,3) ; clreol() ;
}
} while ( valid == 0 ) ;
for ( int i=11; i<=14; i++ )
{
gotoxy(1,i) ; clreol() ;
}
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM NUMBER" ;
gotoxy(13,4) ;
cin>>t_roomno ;
getch();
if ( t_roomno <= 0 || t_roomno > 900 )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"IT SHOULD NOT BE NEGATIVE OR ZERO OR GREATER THAN 900" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,4) ; clreol() ;
}
if ( room_found( t_roomno ) )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. ALREADY EXIST" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,4) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM STATUS : V=vacant, O=occupied" ;
gotoxy(13,5) ;
cin>>t_status ;
t_status = toupper(t_status) ;
if (t_status != 'O' && t_status != 'V')
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"INVALID DATA ENTERED" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,5) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE TARIFF FOR THE ROOM" ;
gotoxy(13,6) ;
cin>>t_tariff ;
getch();
if ( t_tariff <= 0 )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"IT SHOULD NOT BE NEGATIVE OR ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,6) ; clreol() ;
}
} while ( !valid ) ;
gotoxy(1,8) ;
cout<<"Do you want to save the record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(42,8) ;
cin>>ch;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,8) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'Y')
{
strcpy(roomcode,t_rcode) ;
roomno = t_roomno ;
status = t_status ;
tariff = t_tariff ;
file.write((char *) this, sizeof(room)) ;
}
gotoxy(1,9) ;
cout<<"Do you want to add more records (y/n) : " ;
do
{
valid = 1 ;
gotoxy(42,9) ;
cin>>ch;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,9) ; clreol() ;
}
} while ( !valid ) ;
file.close () ;
} while ( ch == 'Y') ;
}
void room :: modify(void)
{
clrscr() ;
int valid ;
char ch ;
char t_rcode[5] ;
int t_roomno , tr ;
char t_status ;
float t_tariff ;
fstream file ;
file.open("ROOM.DAT", ios::out | ios::ate) ;
gotoxy(1,3) ;
cout<<"Enter the Room no. to be modified " ;
cin>>tr ;
getch();
if ( !room_found( tr ) )
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
return ;
}
display_record(tr) ;
gotoxy(1,10) ;
cout<<"Do you want to modify this Room Record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(48,10) ;
cin>>ch;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,9) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'N')
return ;
gotoxy(1,12) ;
cout<<"ENTER THE NEW DATA FOR THE ROOM" ;
gotoxy(1,14) ;
cout<<"Code : " ;
gotoxy(1,15) ;
cout<<"Room no. : " ;
gotoxy(1,16) ;
cout<<"Status : " ;
gotoxy(1,17) ;
cout<<"Tariff : " ;
do
{
valid = 1 ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM CODE (SS/SR/DR/DS)" ;
gotoxy(13,14) ;
cin>>t_rcode ;
getch();
strupr(t_rcode) ;
char *string[4] = {"SS","DR","SR","DS"} ;
int result , count = 0 ;
for ( int i=0; i<4; i++ )
{
result = strcmpi(t_rcode,string[i]) ;
if ( result != 0 )
count++ ;
}
if ( count == 4 )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"INVALID CODE" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,14) ; clreol() ;
}
} while ( valid == 0 ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM NUMBER" ;
gotoxy(13,15) ;
cin>>t_roomno ;
getch();
if ( t_roomno <= 0 || t_roomno > 900 )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"IT SHOULD NOT BE NEGATIVE OR ZERO OR GREATER THAN 900" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,15) ; clreol() ;
}
if ( room_found( t_roomno ) && t_roomno != tr )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. ALREADY EXIST" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,15) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM STATUS : V=vacant, O=occupied" ;
gotoxy(13,16) ;
cin>>t_status ;
getch();
t_status = toupper(t_status) ;
if (t_status != 'O' && t_status != 'V')
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"INVALID DATA ENTERED" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,16) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE TARIFF FOR THE ROOM" ;
gotoxy(13,17) ;
cin>>t_tariff ;
getch();
if ( t_tariff <= 0 )
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"IT SHOULD NOT BE NEGATIVE OR ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,17) ; clreol() ;
}
} while ( !valid ) ;
gotoxy(1,19) ;
cout<<"Do you want to save the record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(42,19) ;
ch = getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,19) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'Y')
{
int recno ;
recno = recordno(tr) ;
int location ;
location = (recno-1) * sizeof(room) ;
file.seekp(location) ;
strcpy(roomcode,t_rcode) ;
roomno = t_roomno ;
status = t_status ;
tariff = t_tariff ;
file.write((char *) this, sizeof(room)) ;
}
file.close () ;
}
void room :: deletion(void)
{
clrscr() ;
int valid ;
char ch ;
int t_roomno ;
gotoxy(1,3) ;
cout<<"Enter the Room no. to be deleted " ;
cin>>t_roomno ;
if ( !room_found( t_roomno ) )
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
return ;
}
display_record(t_roomno) ;
gotoxy(1,10) ;
cout<<"Do you want to delete this Room Record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(48,10) ;
cin>>ch ;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,9) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'N')
return ;
fstream file ;
file.open("ROOM.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(room)) ;
if ( file.eof() )
break ;
if ( roomno != t_roomno )
temp.write((char *) this, sizeof(room)) ;
}
file.close() ;
temp.close() ;
file.open("ROOM.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(room)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(room)) ;
}
file.close() ;
temp.close() ;
}
void customer :: display_list(void)
{
clrscr() ;
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0) ;
int row = 5 ;
int found = 0 ;
int pageno = 1 ;
int total = 0 ;
gotoxy(18,1) ;
cout<<"LIST OF CUSTOMERS" ;
gotoxy(1,3) ;
cout<<" Room no. Name Phone Room service Advance Misc." ;
while (file.read((char *) this, sizeof(customer)))
{
total++ ;
found = 1 ;
gotoxy(2,row) ;
cout<
puts(name) ;
fflush(stdout) ;
gotoxy(34,row) ;
cout<
cout<
cout<
cout<
{
row = 5 ;
gotoxy(66,1) ;
cout<<"Page no. : " <
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
clrscr() ;
gotoxy(18,1) ;
cout<<"LIST OF CUSTOMERS" ;
gotoxy(1,3) ;
cout<<" Room no. Name Phone Room service Advance Misc." ;
}
else
row++ ;
}
if ( found==0 )
{
gotoxy(1,5) ;
cout<<"Records not found" ;
}
gotoxy(66,1) ;
cout<<"Page no. : " <
cout<<"Press any key to continue..." ;
getch() ;
clrscr() ;
gotoxy(5,5) ;
cout<<"Total no. of Customers = " <
cout<<"Press any key to continue..." ;
getch() ;
file.close () ;
}
void customer :: display_record(int t_roomno)
{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0) ;
int found = 0 ;
while (file.read((char *) this, sizeof(customer)) && !found)
{
if (t_roomno == roomno)
{
found = 1 ;
gotoxy(1,5) ;
cout<<"Room no. : " <
cout<<"Customer Name : " <
cout<<"Phone no. : " <
cout<<"Advance : " <
cout<<"Misc. charges : " <
cout<<"Room Service Charges : " <
}
file.close () ;
}
int customer :: recordno(int t_roomno)
{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0) ;
int count = 0 ;
while (file.read((char *) this, sizeof(customer)))
{
count++ ;
if (t_roomno == roomno)
break ;
}
file.close() ;
return count ;
}
void customer :: modify(void)
{
clrscr() ;
room r ;
int valid ;
char ch ;
int t_roomno , tr ;
char t_name[21] , t_phone[8] ;
float t_advance , t_misc , t_room_srv ;
fstream file ;
file.open("CUSTOMER.DAT", ios::out | ios::ate) ;
gotoxy(1,3) ;
cout<<"Enter the Room no. of the customer to be modified " ;
cin>>tr ;
getch();
char t_status ;
t_status = r.room_status(tr) ;
if (!r.room_found(tr) || t_status == 'V')
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND OR ROOM IS VACANT" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
return ;
}
display_record(tr) ;
gotoxy(1,12) ;
cout<<"Do you want to modify this Room Record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(48,12) ;
cin>>ch;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,12) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'N')
return ;
gotoxy(1,14) ;
cout<<"ENTER THE NEW DATA FOR THE CUSTOMER" ;
gotoxy(1,16) ;
cout<<"Room no. : " ;
gotoxy(1,17) ;
cout<<"Name : " ;
gotoxy(1,18) ;
cout<<"Phone : " ;
gotoxy(1,19) ;
cout<<"Advance : " ;
gotoxy(1,20) ;
cout<<"Miscellineous : " ;
gotoxy(1,21) ;
cout<<"Room service : " ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM NUMBER FOR CUSTOMER : " ;
gotoxy(20,16) ;
cin>>t_roomno ;
getch();
t_status = r.room_status(t_roomno) ;
if ((!r.room_found(t_roomno)) || (r.room_found(t_roomno) && t_roomno != tr && t_status == 'O'))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT EXIST OR NOT VACANT" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,16) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE NAME OF THE CUSTOMER : " ;
gotoxy(20,17) ;
gets(t_name) ;
getch();
strupr(t_name) ;
fflush(stdin) ;
if ((strlen(t_name) <= 0) || (strlen(t_name) > 20))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT BE ZERO OR GREATER THAN 20" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,17) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE PHONE NO. OF THE CUSTOMER, ENTER '-' FOR NO PHONE NO." ;
gotoxy(20,18) ;
cin>>t_phone ;
if ((strlen(t_phone) < 8 && strlen(t_phone) > 1) || (strlen(t_phone) > 8))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT LESS THAN 8 OR GREATER THAN 8" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,18) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ADVANCE RS. " ;
gotoxy(20,19) ;
cin>>t_advance ;
getch();
if (t_advance < 0)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,19) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE MISCALLENIOUS CHARGES" ;
gotoxy(20,20) ;
cin>>t_misc ;
getch();
if (t_misc < 0)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,20) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM SERVICE CHARGES" ;
gotoxy(20,21) ;
cin>>t_room_srv ;
getch();
if (t_room_srv < 0)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,21) ; clreol() ;
}
} while ( !valid ) ;
gotoxy(1,23) ;
cout<<"Do you want to save the record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(42,23) ;
cin>>ch;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,23) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'Y')
{
if (t_roomno != tr)
{
r.change_status(t_roomno,'O') ;
r.change_status(tr,'V') ;
}
int recno ;
recno = recordno(tr) ;
int location ;
location = (recno-1) * sizeof(customer) ;
file.seekp(location) ;
roomno = t_roomno ;
strcpy(name,t_name) ;
strcpy(phone,t_phone) ;
room_srv = t_room_srv ;
advance = t_advance ;
misc = t_misc ;
file.write((char *) this, sizeof(customer)) ;
}
file.close () ;
}
void customer :: delete_record(int t_roomno)
{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(customer)) ;
if ( file.eof() )
break ;
if ( roomno != t_roomno )
temp.write((char *) this, sizeof(customer)) ;
}
file.close() ;
temp.close() ;
file.open("CUSTOMER.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(customer)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(customer)) ;
}
file.close() ;
temp.close() ;
}
void customer :: display_customer_record(void)
{
clrscr() ;
room r ;
int valid ;
int t_roomno ;
gotoxy(1,3) ;
cout<<"Enter the Room no. of the customer : " ;
cin>>t_roomno ;
char t_status ;
t_status = r.room_status(t_roomno) ;
if (!r.room_found(t_roomno) || t_status == 'V')
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND OR ROOM IS VACANT" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
return ;
}
clrscr() ;
gotoxy(5,3) ;
cout<<"CUSTOMER RECORD" ;
display_record(t_roomno) ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
}
void customer :: deletion(void)
{
clrscr() ;
room r ;
int valid ;
char ch ;
int t_roomno ;
gotoxy(1,3) ;
cout<<"Enter the Room no. of the customer to be deleted " ;
cin>>t_roomno ;
char t_status ;
t_status = r.room_status(t_roomno) ;
if (!r.room_found(t_roomno) || t_status == 'V')
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND OR ROOM IS VACANT" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
return ;
}
display_record(t_roomno) ;
gotoxy(1,15) ;
cout<<"Do you want to delete this Customer Record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(52,15) ;
cin>>ch ;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(52,15) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'N')
return ;
r.change_status(t_roomno,'V') ;
delete_record(t_roomno) ;
}
void customer :: checkout(void)
{
clrscr() ;
menu m1 ;
room r ;
int valid ;
char ch ;
int t_roomno ;
gotoxy(1,3) ;
cout<<"Enter the Room no. of the customer to be check out " ;
cin>>t_roomno ;
char t_status ;
t_status = r.room_status(t_roomno) ;
if (!r.room_found(t_roomno) || t_status == 'V')
{
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND OR ROOM IS VACANT" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
m1.main_menu();
}
display_record(t_roomno) ;
gotoxy(1,15) ;
cout<<"Do you want to prepare bill of this Customer Record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(63,15) ;
cin>>ch;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(63,15) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'N')
return ;
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0) ;
char t_name[21] ;
float t_advance, t_room_srv, t_misc, t_tariff ;
while (file.read((char *) this, sizeof(customer)))
{
if (t_roomno == roomno)
{
strcpy(t_name,name) ;
t_advance = advance ;
t_room_srv = room_srv ;
t_misc = misc ;
break ;
}
}
file.close() ;
t_tariff = r.get_data(t_roomno) ;
account a ;
a.prepare_bill(t_roomno,t_tariff,t_name,t_advance,t_room_srv,t_misc) ;
r.change_status(t_roomno,'V') ;
delete_record(t_roomno) ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
m1.main_menu() ;
}
void account :: prepare_bill(int t_roomno, float t_tariff, char t_name[21], float t_advance, float t_room_srv, float t_misc)
{
menu m1 ;
int valid ;
int days ;
float tax , total ;
gotoxy(1,17) ;
cout<<"Enter the no. of days : " ;
do
{
valid = 1 ;
gotoxy(25,17) ;
cin>>days ;
if (days < 0 || days > 2000)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(25,17) ; clreol() ;
}
} while ( !valid ) ;
t_tariff = t_tariff * days ;
total = (t_room_srv + t_misc + t_tariff) - t_advance ;
tax = total * 0.22 ;
total = total + tax ;
clrscr() ;
menu m ;
gotoxy(5,3) ;
cout<<"Bill of Room no. : " <
cout<<"Name of Customer : " <
cout<<"Tariff Charges : " <
cout<<"Misc. Charges : " <
cout<<"Room service Charges : " <
cout<<"Tax : " <
cout<<"Advance : " <
cout<<"------------------------------------------" ;
gotoxy(5,19) ;
cout<<"Total Bill : " <
cout<<"------------------------------------------" ;
}
void main()
{
menu m ;
m.enter_password() ;
m.intro();
}
Subscribe to:
Comments (Atom)