Академический Документы
Профессиональный Документы
Культура Документы
Q5) Define a class Travel in C++ with the description given below :
Private Members
T_code of type string
No_of_adults of type integer
No_of_children of type integer
Distance of type integer
TotalFare of type float
Public Members
A constructor to assign initial values as follows :
T_Code with the word “NULL”
No_of_adults as 0
No_of_children as 0
Distance and TotalFare as 0
A function AssignFare( ) which calculates and assigns the value of the data member
TotalFare as follows :
For each Adult
Fare (Rs) For Distance (Km)
500 >=1000
300 <1000 and >=500
200 <500
For each child the above Fare will be 50% of the Fare mentioned in the given table
For example : If distance is 750, No_of_adults = 3 and No_of_children=2
Then TotalFare should be calculated as
No_of_adults * 300 + No_of_children * 150
i.e. 3 * 300 + 2 * 150 = 1200
Q6) Define a class named MOVIE in C++ with the following description :
Private Members
Hall_no integer
Movie_name Array of characters(string)
Weeks integer
Week_collection float
Total_collection float
Public members
Function Read_Data( ) to read an object of MOVIE type
Function Display( ) to display the details of an object
Function Update( ) to update the total collection and weekly collection when the week
changes. Total collection will be incremented by weekly collection and weekly collection
is made zero.
Q7) Define a class named HOUSING in C++ with the following description :
Private Members
Reg_no integer (ranges 10 – 1000)
Name String
Type Character
Cost float
Public Members
Function read_data( ) to read an object of HOUSING type.
Function display( ) to display the details of an object.
Function draw_nos( ) to choose and display the details of 2 houses selected randomly
from an array of 10 objects of type HOUSING. Use random function to generate the
registration nos. to match with Reg_no from the array.
Q10) Define a class with complete function definitions COMPETITION in C++ with
following specifications :
Private members
Event_no integer
Description char(30)
Score integer
Qualified char
Public members
Input( ) To take input for event_no, description and score.
Award( ) to assign qualified as ‘y’ if score is more than the cut off score passed as int to
the function, else assign ‘n’.
Show( ) to display all details.
Public members
-A constructor function to initialize Price, Stockqty and Stockvalue as 0.
-Enter( ) function to input the IDNumber, Title and Author
-TakeStock( ) function to increment Stockqty by N (where N is passed as argument to
this function) and call the function Valcal( ) to update the Stockvalue.
-Sale( ) function to decrease the Stockqty by N (where N is sale quantity passed to this
function as argument) and also call the function Valcal( ) to update the Stockvalue.
-Outdata( ) function to display all the data members on the screen.
Q16) Define a class Bank to represent a bank account with the data members as name of
depositor, account number, type of account( S for Savings and C for current), and balance
amount. The class also contains member functions to do the following :
-To initialize the data members
-To read the data members
-To display the data members
- To deposit money
-To withdraw money after checking balance. Minimum balance must be 1000.