Monday, 1 February 2016

practice question for class & object

Class & Object 4 marks
1.       Define a class practical _record with following details
Private member
Experiment_no of integer type to store experiment number
Title   of string type to store title of the experiment
Guide_by   of string type to store the name of teacher  who guide for practical
Grade   of character type store the grade ‘A’, ‘B’ ,‘C’,’D’,’E’,’F’ calculated by function assign_grade() function
Marks of integer type to store the marks awarded for the experiment out of 10
Void Assign_grade()
To assign grade as per following details
Marks                                                                   grade
>9                                                                                A
>8                                                                                B
>7                                                                                C
>6                                                                                D
>5                                                                                E
<5                                                                                F                        
Public member
Void Get_details() / / to take input for Experiment_no, Title,Guide_by,Marks
Void Show_details()// to show all details of experiment and also call the function Assign grade

2.       Define a class folder with following details
Private members
Name of string type to store name of folder
Total_Size of type long to store the memory occupied by the folder
Owner  of type string to store the name of user who create the folder
No_of _files of integer type to store number of file stored in folder
Size to store the required size of new file
Void Add_files()   ask user to input size of file  and calculate the  Total_size=Total_size+size And No_of_ Files=No_of_files+1
Public members
A constructor to initialize Total_size=0 No_of_files=0
Void get() to take input of Name, owner and call the function Add_files()
Void show files to show all details of folder class
3.       Define a class Cricket with following details
Team1 of string type to store the name of country from which team1 belongs
Team2  of string type to store the name of country from which team2 belongs
Captain1 of string type to store the name of  to store the name of captain of team1
Captain2 of string type to store the name of  to store the name of captain of team2
Score1,score2 of type integer to score the run scored by team1,and team2
Winner of string type to store the name of winning team country
Void select_winner() to store  the name of winning team country in winner  by comparing the score of team1 and team2
Public member
Constructor to initialize Team1 as India and Team2  as Australia
Void get() to take input captain1, captain2,score1 and score2
Void show to display team1 , team2, captain1, captain2,score1 and score2 and call the function select_winner()


4.        Define a class Income_tax with following details
Private members
Total_income to store the total income
Name of string type to store the name of employee
Savings of type float to store the total savings done by employee
Tax_income to store the taxable_income
Gender of type character to store “M” for male and “F” for female
Tax of float type to store tax to be paid by employee
Void Calc_tax() to calculate tax_income and tax as 10% of tax_income
Savings can be done maximum 1,50,000 if saving is more than 1,50,000 it will be equal to 1,50,000 only
For female Tax_income is Total_income_2,50,000-savings
For male Tax_income is Total_income_2,00,000-savings
Tax=10% of tax_income
Public member
Void get() to take input of Total_income,Savings, Name and gender as “M” or “F” and call the function void Calc_tax()
Void show() to show all details

5.       Define a class student with following details
Name of string type to store name of student
Age of float type to store age of students
Marks to store marks obtained by students out of 100
Grade of character type o store A,B,C,D,E,OR F grade
Void Calc_grade() to set the value of grade according to marks
Marks                   grade
A                             >90        
B                             >80                        
C                             >70
D                             <70
PUBLIC MEMBER
Void get() to take input of all required details and also call the function Calc_grade()

Void show () to show all details of student class