Create a structure called volume that uses three variables of type Distance (structure) to model the volume of a room. Initialize a variable of type volume to specific dimensions, and then calculate the volume it represents and print out the result.
#include<iostream>
#include<conio.h>
using namespace std;
struct volume
{
int length,width,height,l_inch,w_inch,h_inch;
};
int main()
{
volume v;
cout<<"Enter feet then inches"<<endl;
cout<<"Enter the length of room (feet and inches) : ";
cin>>v.length>>v.l_inch;
cout<<"Enter the width of room (feet and inches) : ";
cin>>v.width>>v.w_inch;
cout<<"Enter the Height of room (feet and inches) : ";
cin>>v.height>>v.h_inch;
float length,width,height,volume;
length=v.length+((float)(v.l_inch)/12);
width=v.width+((float)(v.w_inch)/12);
height=v.height+((float)(v.h_inch)/12);
cout<<"The length of room in foot is : "<<length<<endl;
cout<<"The Base of room in feet is: "<<width<<endl;
cout<<"The Height of room in feet is : "<<height<<endl;
volume=length*width*height;
cout<<"Volume of Room is: "<<volume;
}
Comments
Leave a comment