-
Notifications
You must be signed in to change notification settings - Fork 23
/
3.cpp
35 lines (27 loc) · 927 Bytes
/
3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
Create a structure called Volume that uses three variables of type Distance (from the
ENGLSTRC example) to model the volume of a room. Initialize a variable of type Volume
to specific dimensions, then calculate the volume it represents, and print out the result.
To calculate the volume, convert each dimension from a Distance variable to a variable
of type float representing feet and fractions of a foot, and then multiply the resulting
three numbers.
*/
// author @Nishant
#include<iostream>
using namespace std;
struct Distance{
int feet;
float inch;
};
struct Volume{
Distance length, width, height;
};
int main(){
float len, wid, hei;
Volume room1 = {{13, 2.5}, {11, 5.5}, {5,2.5}};
len = room1.length.feet+ room1.length.inch/12;
wid = room1.width.feet+ room1.width.inch/12;
hei = room1.height.feet+ room1.height.inch/12;
cout << "Volume = " << len * wid * hei << " cubic feet" << endl;
return 0;
}