Answer to Question #264874 in C++ for Cedric Bernardo

Question #264874

Write a program that reads in a room number, the room’s capacity, and the size of the class enrolled so far, and prints an output line showing the class room number, the capacity, number of students enrolled, number of seats available, and whether the class is closed or not.


1
Expert's answer
2021-11-12T16:31:44-0500
#include<iostream>

using namespace std;

class room {
	int l;
	int b;
	int h;
	public : 
		void getroom()
		{
			cout<<"Enter length, breath, height: ";
			cin>>l>>b>>h;
		}
		void putroom()
		{
			cout<<"Length: "<<l<<",Breath: "<<b<<", Height: "<<h<<endl;
		}
};
class address {
	int hno;
	char cty[30];
	char state[30];
	public : 
		void getad()
		{
			cout<<"house number : ";
			cin>>hno;
			cout<<"city :";
			cin>>cty;
			cout<<"state : ";
			cin>>state;
		}
		void putad()
		{
			cout<<"House No.: "<<hno<<",city: "<<cty<<",state: "<<state<<endl;
		}
};

class house{
	char housename[30];
	address a;
	room r[10]; //max. 10 rooms

	public : 
			void input();
			void display();
};
//function definition
void house :: input()
{	
	cout<<"Enter house name: ";
	cin>>housename;
	cout<<"Enter Address : \n";
	a.getad();
	
	for(int i=0;i<3;i++){
		cout<<"House Details : "<<i+1<<"\n";
		r[i].getroom();
	}
}

//function definition
void house :: display()
{	
	cout<<"House name: "<<housename<<endl;
	cout<<"Address is: ";
	
	for(int i=0;i<3;i++){
		cout<<"House Details : "<<i+1<<"\n";
		r[i].putroom();
	}
}

int main()
{
	house x;
	x.input();
	x.display();
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS