Thursday 02nd May 2024
REGISTRATION
Online Fashion Store

CBSE Computer Science - Revision Tour(Solved)

CBSE Guess > eBooks > Class XII > CBSE Computer Science Class And Object Solved Revision Tour By Mr. Ravi Kiran

COMPUTER SCIENCE CLASS AND OBJECTS

Previous Index Next

2. c) Define a class named HOUSING in C++ with the following descriptions:

Private Members:

REG_NO    integer(Ranges 10-1000)
NAME          Array of characters(String)
TYPE          Character
COST          Float

Public Members:

Function Read_Data( ) to rread an object of HOUSING type.
Function Display( ) to display the details of an object.
Function Draw_Nos( ) to choose and displaym 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.

4

Ans:

class HOUSING
{ int REG_NO;
char NAME[31];
char TYPE;
float COST;
public:
void Read_Data( )
{ cout<<"\nEnter the House Registration Number: ";
cin>>REG_NO;
cout<<"\nEnter the House Name: ";
gets(NAME);
cout<<"\nEnter the House Type: ";cin>>TYPE;
cout<<"\nEnter the House Cost: ";
cin>>COST;
}
void Display()
{ cout<<"\nThe Registration Number of the
House: "<<REG_NO;
cout<<"\nThe name of the House: “ <<NAME;
cout<<"\nThe Type of the House: "<<TYPE;
cout<<"\nThe Cost of the House: "<<COST;
}
void Draw_Nos();
};
void HOUSING::Draw_Nos( )
{ //Dear Students, a test for you. Completethis member function.
}

 

Previous Index Next

CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] )