"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Friday, January 22, 2010

Create a structure called volumn that uses three variables (lenght, width, height ) of type distance (feet and inches) to model the volume of a room. Read the three dimensions of the room and calculate the volumn it represents , and print out the result. The volumn should be in cu. feet form, i.e., you will have to convert each dimension in to feet and fractions of foot. For instance , the lenght 12 feet 6 inches will be 12.5 feet.



#include<iostream.h>
#include<conio.h>

struct vol {
int  l_in_feet, b_in_feet, h_in_feet;
int l_in_inch, b_in_inch, h_in_inch;
};

void main()
{
vol room;
char ch[10];
cout << “\n Enter  length in feet and inches(XfeetXinch/X F. X I.) :”
cin >> l_in_feet >> ch >> l_in_inch >> ch;
cout << “\n Enter breadth  in feet and inches (XfeetXinch..):”
cin >> b_in_feet >> ch >> b_in_inch >> ch;
cout << “\n Enter  height in feet and inches(XfeetXinch…)  :”
cin >> h_in_feet >> ch >> h_in_inch >> ch;

float len, br, height;

len = l_in_feet + (float)(l_in_inch/12);
br = b_in_feet + (float)(b_in_inch/12);
height = h_in_feet + (float)(h_in_inch/12);
double  volm = (double)len * br*height;

cout<< “\n The Length  of the Room = “ << len << “feet”;
cout<< “\n The Breadth of the Room = “ << br << “feet”;
cout<< “\n The Volume of the Room = “ << height << “feet”;
cout<< “\n The Volume of the Room = “ << volm << “c.feet”;
getch();
}

No comments:

Post a Comment

C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.