Tuesday, 6 August 2013

Questions on Classes and Objects


Classes and objects:

1)Define a class to represent a book in a library. Include the following members:
Data Members
Book Number,Book Name,Author,Publisher,Price,No of copies, No.of copies issued
Member functions
1)To assign initial value                                  2)To issue a book after checking for its availability
3)To return a book                                          4)To display book information

2)Declare a class to represent fixed deposit account of 10 customers with the following data memers :
Name of the depositor, Account Number, Timer Period (1 or 4 or 5 years), Amount. The class also contains following member function:
a)To initialize data members                                       b)For withdrawl of money (after half of the time period has passed)
c)To display the data members

3)Define a class to represent batsmen in a cricket team.Include the following members:
Data Members :
First Name, Last Name, Runs made, Number of fours, Number of sixes.
Member functions
1)To assign the initial values
2)To update runs made (It should simultaneously update fours and sixes, if required )
3)To display the batsman’s information
Make appropriate assumption about access labels

4)Write a program to manage a rooms statistics. The room class includes the following members :
Data Members :
Length, Width, Height
Member Functions :
a)To assign initial values                                                                b)To calculate area
c)To display information (length,width,height & area)

5)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 :
1)To initialize data members                       2)To deposit money
3)To withdraw money after checking the balance (min.balance in Rs.1000)
4)To display the data members.

6)Define a class worker with the following specification :
Wname                25 characters
hrwrk,wgrate    float(hours worked and wagerate per hour)
totwage                               float(hrwrk * wgrate)
calcwg()               A function to find hrwrk * wgrate with float return type
Public member function of class worker
                in_data()                             a function to accept values for wno,wname,hrwrk,wgrate and invoke calcwg() to calculate totwage
Out_data()         a function to display all the data members on the screen you should give definitions of functions.

7)Define a class teacher with the following specification :
a)name                                                20 characters
b)subject                             10 characters
c)Basic,Da,Hra                   float
d)salary                                                float
                Calculate() function computes the salary and returns it.
Salary is sum of Basic,DA, HRA
public members:
ReadData()function accepts the data values and invoke the calculate functions.
DisplayData() function prints the data on the screen
8)Define a class student with the following specification:
Private mebers :
Roll_no                                 integer
name                                    20 characters
class                                       8 characters
marks[5]                              integer
Percentage                         float
Calculate() function that calucates overall percentage of marks and returns the percentage of marks
Public members:
ReadMarks() a function that reads marks and invokes the calculate functions
Displaymarks() a functions that prints the marks

9)Imagine a ticket selling booth at a fair. People passing by are requested to purchase a ticket. A ticket is priced as Rs.2.50/.The booth keeps track of the number of people that have visited the booth, and of the  total amount of money collected.
Model this ticketselling booth with a class called ticbooth including the following members :
Data Members :
1)number of people visited
2)total amount of money collected.
Member Functons:
1) To assign initial values(assign 0 to both data members )
2)To increment only people total in case ticket is not sold out.
3)To increment people total as well as amount total if a ticket is sold out.
4)To display the two totals
5)To display the number of tickets sold out(a tricky one)

10) Write a C # program to perform various operations on  a string class without using without using lanugae supported built in string functions. The operations on a class are:
a)Read a string                                  b)Display  the string
c)Reverse the stirng                       d)Copy the string into an empty string
e)Concatenate two strings.


11)A book shop maintains the inventory of books that are being sold at the shop. The list includes details such as author, title , price,publisher and stock position.Whenever a customer want a book, the sales person inputs the title and author and the system searches the list and displays whether it is available or not. If it is not, an appropriate message is displayed.If it is then the system displays the book details and requests for the number of copies required. If the requested copies are available, the total cost of the required copies is displayed, otherwise the message “Sorrry”! These many copies are not in stock” is displayed.
Design a system using a class called stock with suitable member functions and constructors.


12)Imagine a publishing company that markets both books and audio-cassette versions of its works. Create a class publication that stores the title and price of a publication.From this class derive two classes : BOOK which adds a page count and TAPE which adds a playing time in minutes. Each of these three classes should have a getdata() functions to get its data from the user at the keyboard and a putdata() function to display its data. Write a main() program to test the book and tape classes by creating instances of them, asking the user to fill in their data with getdata() and then displaying the data with putdata().
3)Write a C sharp to read and display information about employees and managers.EMPLOYEE is a class that contains employee number, name, address and department. Manager class contains all information of the employee class and a list of employees working under a manger.




0 comments:

Post a Comment