Vous êtes sur la page 1sur 11

Class 12 Important Questions from various Board

1. Define a class employee with the following specifications :


private members of class employee
empno integer
ename 20 characters
basic, hra, da float
netpay float
calculate() A function to calculate basic + hra + da with float return type
public member function of class employee
havedata() function to accept values for empno, sname, basic, hra, da and invoke
calculate() to calculate netpay.
dispdata() function to display all the data members on the screen.

2. Define a class Student with the following specifications :


private members:
roll_no integer
name 20 characters
class 8 characters
marks[5] integer
percentage float
Calculate() a function that calculates overall percentage of marks and return the
percentage of marks.
public members :
Readmarks() a function that reads marks and invoke the Calculate function.
Displaymarks() a function that prints the marks.

3. Define a class report with the following specification :


Private members :
adno 4 digit admission number
name 20 characters
marks an array of 5 floating point values
average average marks obtained
getavg() to compute the average obtained in five subjects
Public members :
readinfo() function to accept values for adno, name, marks, and invoke the function
getavg().
displayinfo() function to display all data members on the screen you should give
function definitions.

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

5. Define a class Student for the following specifications.


Private members of the Student are :
roll_no integer
name array of characters of size 20
class_st array of characters of size 8
marks array of integers of size 5
percentage float
calculate that calculates overall percentage marks and returns the percentage
Public members of the Student are :
readmarks reads mark and invoke the calculate function
displaymarks prints the data

6. Define a class Play in C++ with the following specifications :


private members of class Play
Playcode integer
Playtitle 25 character
Duration float
Noofscenes integer
public member function of class Play
A constructor function to initialise Duration as 45 and Noofscenes as 5.
NewPlay( ) function to accept values for Playcode and Playtitle.
Moreinfo( ) function to assign the values of Duration and Noofscenes with the help of
corresponding values passed as parameters to this function.
Shoplay( ) function to display all the data members on the screen.

7. Declare a class myfolder with the following specification :


Private members of the class
Filenames – an array of strings of size[10][25]
( to represent all the names of files inside myfolder)
Availspace – long ( to represent total number of bytes available in myfolder)
Usedspace – long ( to represent total number of bytes used in myfolder)
public members of the class
Newfileentry() – A function to accept values of Filenames, Availspace and Usedspace
from user
Retavailspace() – A Fucntion that returns the value of total Kilobytes available ( 1
Kilobytes = 1024 bytes)
Showfiles() – a function that displays the names of all the files in myfolder

8. Define a class Tour in C++ with the description given below :


Private Members :
TCode of type string
NoofAdults of type integer
NoofKids of type integer
Kilometres of type integer
TotalFare of type float
Public Members :
• A constructor to assign initial values as follows :
TCode with the word “NULL”
NoofAdults as 0
NoofKids as 0
Kilometres as 0
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 Kilometres
500 >=1000
300 <1000 and >=500
200 <500

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.

9. Define a class RESORT in C++ with following description:


Private Members:
Rno // Data member to store Room No
Name // Data member to store customer name
Charges // Data member to store per day charges
Days // Data member to store number of days of stay
COMPUTE( ) // A function to calculate and return Amount as
Days* Charges and if the value of Days * Charges
is more than 11000 then as 1.02 * Days * Charges
Public Members :
Getinfo( ) // A function to enter the content Rno, Name, Charges and Days
Dispinfo( ) // A function to display Rno, Name, Charges, Days and Amount
(Amount to be displayed by calling function COMPUTE( ) )

10. Define a class ITEM in C++ with the following description :


Private Members
Code of type integer (Item Code)
Iname of type string (Item Name)
Price of type float (Price of each item)
Qty of type integer (Quantity of item in stock)
Offer of type float (Offer percentage on the item)
A member function GetOffer( ) to calculate Offer percentage as per the
following rule :
If Qty <= 50 Offer is 0
If 50 < Qty <= 100 Offer is 5
If Qty >100 Offer is 10
Public Members
A function GetStock( ) to allow user to enter values for Code, Iname, Price, Qty
and call function GetOffer( ) to calculate the offer.
A function ShowItem( ) to allow user to view the content of all the data members.

11. Define a class candidate in C++ with following Description:


Private Members
A data member RNo (Registration Number) of type long
A data member Name of type string
A data member Score of type float
A data member Remark of type string
A member function AssignRem( ) to assign Remarks as per the Score obtained by a
candidate. Score range and the respective Remarks are shown as follows:
Score Remarks
>=50 Selected
less than 50 Not selected
Public members
A function ENTER( ) to allow user to enter values for RNo, Name, Score & call
function AssignRem() to assign the remarks.
A function DISPLAY( ) to allow user to view the content of all the data members.

12. Define a class batsman with the following specifications :


Private members :
bcode (4 digit code number)
bname (20 characters)
innings, notout, runs integer type
batavg it is calculated according to the formula : batavg = runs/(innings-notout)
calcavg() function to compute batavg
Public members :
readdata() function to accept values for bcode, name, innings, notout and invoke the
function calcavg()
displaydata() function to display the data members on the screen.

13. Define a class DONOR with the following specification :


Private :
Donor number integer
Name 20 characters
Blood group 2 characters
Public :
Input( ) A function to accept all the information
Output( ) A function to display all the information
Checkgroup( ) A function with char* return type to return Blood Group
Define both the number functions with their given description.

14. Define a class Library for the following specifications :


Private members of the Library are
name array of characters of size 20
english_books, hindi_books, others, and total_books integers, compute that
calculates the total number of books and return the total. Total books are the sum of
english_books, hindi_books, and others.
Public members of the Library are
readdata accepts the data and invokes the compute function.
printdata prints the data.

15. Define a class PUBLISHER in C++ with the following specifications :


private members of class PUBLISHER
- IDNumber long
- Title 40 character
- Author 40 character
- Price, StockQty double
- StockValue double
- Valcal() A function to find Price * StockQtu with double as return type
- Duration float
- Noofepisodes integer
public member function of class PUBLISHER
- A constructor function to initialise Price, StockQty and StockValue as 0
- Enter( ) function to input IDNumber, Title ad Aughor
- 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

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()

19. Define a class TEST in C++ with following description:


Private Members
a. TestCode of type integer
b. Description of type string
c. NoCandidate of type integer
d. CenterReqd (number of centers required) of type integer
e. A member function CALCNTR() to calculate and return the number of centers as
(NoCandidates/100+1)
Public Members
A function SCHEDULE() to allow user to enter values for TestCode, Description,
NoCandidate & call function CALCNTR() to calculate the number of Centres
A function DISPTEST() to allow user to view the content of all the data
members

20. Define a class in C++ with following description: 4


Private Members
• A data member Flight number of type integer
• A data member Destination of type string
• A data member Distance of type float
• A data member Fuel of type float
• A member function CALFUEL() to calculate the value of Fuel as per the
following criteria
Distance Fuel
<=1000 500
more than 1000 and <=2000 1100
more than 2000 2200
Public Members
" A function FEEDINFO() to allow user to enter values for Flight Number,
Destination, Distance & call function CALFUEL() to calculate the quantity of Fuel
" A function SHOWINFO() to allow user to view the content of all the data members

21. Define a class Competition in C++ with the following descriptions:


Private Members:
Event_no integer
Description char(30)
Score integer
Qualified char
Award(int) To award qualified as ‘Y’, if score is more than the cut off score passed as
argument to the function else ‘N’.
Public Members:
A constructor to assign initial values Event_No as 101, Description as “State level”,
Score is 50 and Qualified as ‘N’
Input( ), To take the input for Event_no, Description and Score and call the
function Award( ).
Show( ), To display all the details.

22. Define a class BOOK with the following specifications.


Private members
BOOK_NO integer type
BOOK_TITLE 20 Characters
PRICE float(price per copy)
TOTAL_COST() A function to calculate the total cost for N number of copies,
Where N is passed to the function as argument
Public members
INPUT() Function to read BOO_NO, BOOK_TITLE, PRICE
PURCHASE() Function to ask the user to input the number of copies to be purchased.
It invokes TOTAL_COST() and prints the total cost to be paid by the user.

23. Define a class HandSet in C++ with following description:


Private members:
Make- of type string
Model- of type string
Price- of type long int
Rating- of type char
Public Members:
Function Read_Data to read an object of HandSet type.
Function Display() to display the details of an object of HandSet type.
Function RetPrice() to return the value of Price of an object of HandSet type.

24. Define a class Garments in C++ with the following descriptions:


Private Members:
GCode of type string
GType of type string
GSize of type integer
GFabric of type string
GPrice of type float

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

25. Define a class Clothing in C++ with the following descriptions:


Private Members:
Code of type string
Type of type string
Size of type integer
Material of type string
Price of type float
A function Calc_Price() which calculates and assigns the value of Price as follows:
For the value of Material as “COTTON”
Type Price(Rs.)
TROUSER 1500
SHIRT 1200

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.

27. Define a class DanceAcademy in C++ with following description:


Private Members
● Enrollno of type int
● Name of type string
● Style of type string
● Fee of type float
● A member function chkfee( ) to assign the value of fee variable according to the
style entered by the user according to the criteria as given below:
Style Fee
Classical 10000
Western 8000
Freestyle 11000
Public Members
● A function enrollment() to allow users to enter values for Enrollno,Name, Style
and call function chkfee()to assign value of fee variable according to the Style entered
by the user.
● A function display() to allow users to view the details of all the data members.
28. Define a class Candidate in C++ with the following specification :
Private Members :
A data members Rno(Registration Number) type long
A data member Cname of type string
A data members Agg_marks (Aggregate Marks) of type float
A data members Grade of type char
A member function setGrade () to find the grade as per the aggregate marks obtained
by the student. Equivalent aggregate marks range and the respective grade as shown
below.
Aggregate Marks Grade
>=80 A
Less than 80 and >=65 B
Less than 65 and >=50 C
Less than 50 D
Public members:
A constructor to assign default values to data members:
Rno=0,Cname=”N.A”,Agg_marks=0.0
A function Getdata () to allow users to enter values for Rno. Cname, Agg_marks and
call function setGrade () to find the grade.
A function dispResult( ) to allow user to view the content of all the data members

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.

Vous aimerez peut-être aussi