Kimossab

Room Volume

Oct 25th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3.  
  4. using namespace std;
  5.  
  6. typedef struct Distance
  7. {
  8.     int feet;
  9.     int inches;
  10. }Distance;
  11.  
  12. struct volume
  13. {
  14.     Distance length;
  15.     Distance width;
  16.     Distance heigth;
  17. };
  18.  
  19. void main()
  20. {
  21.     volume room;
  22.     cout << "Insert the length: " << endl;
  23.     cout << "Feet: ";
  24.     cin >> room.length.feet;
  25.     cout << "Inches: ";
  26.     cin >> room.length.inches;
  27.     cout << endl << "Insert the width: " << endl;
  28.     cout << "Feet: ";
  29.     cin >> room.width.feet;
  30.     cout << "Inches: ";
  31.     cin >> room.width.inches;
  32.     cout << endl << "Insert the heigth: " << endl;
  33.     cout << "Feet: ";
  34.     cin >> room.heigth.feet;
  35.     cout << "Inches: ";
  36.     cin >> room.heigth.inches;
  37.  
  38.     float l,w,h,v;
  39.     l = room.length.feet + (float)room.length.inches/12;
  40.     w = room.width.feet + (float)room.width.inches/12;
  41.     h = room.heigth.feet + (float)room.heigth.inches/12;
  42.     v = l*w*h;
  43.     cout << endl << endl << "Volume of the room: " << v << " feet." << endl;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment