COMPUTER SCIENCE CLASS AND OBJECTS

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.
}

 

CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( mrkdata@yahoo.com )


Warning: include_once(../../ebooks-footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/calss_object3.php on line 116

Warning: include_once(): Failed opening '../../ebooks-footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/calss_object3.php on line 116

Warning: include_once(../../../footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/calss_object3.php on line 118

Warning: include_once(): Failed opening '../../../footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/calss_object3.php on line 118