Class Concept Questions
Class Concept Questions
4. Declare a class to represent bank account of 10 customers with the following data
members.
Name of the depositor, Account number, Type of account (S for Savings and C for
Current), Balance amount. The class also contains member functions to do the
following :
(i) To initialize data members
(ii) To deposit money
(iii) To withdraw money after checking the balance (minimum balance is Rs. 1000)
(iv) To display the data members
For each Kid the above Fare will be 50% of the Fare mentioned in
the above table
For example :
If Kilometres is 850, NoofAdults = 2 and NoofKids = 3 Then TotalFare should be
calculated as NumofAdults * 300 + NoofKids * 150 i.e. 2*300 + 3*150=1050
• A function EnterTour( ) to input the values of the data members TCode, NoofAdults,
NoofKids and Kilometres; and invoke the Assign Fare( ) function.
• A function ShowTour( ) which displays the content of all the data members for a
Tour.
16. 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 award qualified as ‘y’ if score is more than the cut off score passed as
int to the function else award ‘N’
show() To display all details
17. Define a class named MOVIE in C++ with the following description
Private members
HALL_NO integer
MOVIE_NAME Array of characters (String)
WEEK integer (Total number of weeks the same movie is shown)
WEEK_COLLECTION Float
TOTAL_COLLECTION Float
Public Members
Function Read_Data( ) to read an object of ADMISSION type
Function Display( ) to display the details of an object
Function Update( ) to update the total collection and Weekly collection once the
week changes. Total collection will be incremented by Weekly collection and Weekly
collection is made Zero.
18. Define a class HOTEL in C++ with the following description : private members :
Rno Room No of int type
Name Customer name of char type
Tarrif stores per day charges of float type
NOD no of days integer
CALC() A function to calculate and return Amount as NOD*Tarrif and if the value of
NOD*Tarrif is
more than 10000 then as 1.05*NOD*Tarrif
Public Members:
Checkin // A function to enter the Rno, Name , Tarrif and NOD
Checkout // A function to display Rno, Name, Tarrif, NOD and Amount by calling
CALC()
A function Assign( ) which calculates and assigns the value of GPrice as follows
For the value of GFabric as “COTTON”,
GType GPrice(Rs)
TROUSER 1300
SHIRT 1100
For GFabric other than “COTTON” the above mentioned GPrice gets reduced by10%.
Public Members:
A constructor to assign initial values of GCode, GType and GFabric with the word
“NOT ALLOTTED” and GSize and GPrice with 0
A function Input( ) to input the values of the data members GCode, GType, GSize and
GFabricl and invoke the Assign( ) function.
A function Display( ) which displays the content of all the data members for a
Garment
For Material other than “COTTON” the above mentioned Price gets reduced by 25%.
Public Members:
A constructor to assign initial values of Code, Type and Material with the word “NOT
ASSIGNED” and Size and Price with 0.
A function Enter () to input the values of the data members Code, Type, Size and
Material and invoke the CalcPrice() function.
A function Show () which displays the content of all the data members for a Clothing.
26. Define a class Movie in C++ with the description given below: 4
Private Members:
Name_of_movie of type character array(string)
Date_of_release of type character array(string)
Name_of_director of type character array(string)
Star of type int
Total_print_release of type int
Public Members:
A constructor to assign initial values as follows:
Name_of_movie NULL
Date_of_release 1/1/2007
Name_of_director NULL
Star 2
Total_print_release 100
A function calculate_star() which caculates and assigns the value of data member Star
as follows:
Total Print Release Star
>= 1000 5
< 1000 & >=500 4
< 500 & >=300 3
< 300 & >=100 2
< 100 1
A function EnterMovie() to input the values of the data members Name_of_movie,
Date_of_release, Name_of_director and Total_print_release
A function ShowMovie() which displays the contents of all the data members for a
movie.
29. Write the definition of a class PlC in C++ with following description:
Private Members
Pno //Data member for Picture Number (an integer)
Category //Data member for Picture Category (a string)
Location //Data member for Exhibition Location (a string)
FixLocation //A member function to assign
//Exhibition Location as per category
//as shown in the following table
Category Location
Classic Amina
Modern Jim Plaq
Antique Ustad Khan
Public Members
Enter()//A function to allow user to enter values
//Pno,category and call FixLocation() function
SeeAll() // A function to display all the data members
30.