-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexercise03.cpp
More file actions
54 lines (46 loc) · 1.48 KB
/
exercise03.cpp
File metadata and controls
54 lines (46 loc) · 1.48 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
using namespace std;
int volume(int height, int width, int length);
// 1. Define a structure called Box
struct Box{
// have the integer data types Height, Width, Length
int height;
int width;
int lenght;
} ;
// Do not change the main function
int main() {
// 2. Create a variable called box1 of the Box structure type
struct Box box1;
// int box1Height, box1Width, box1Length;
int box1height ,box1width,box1length;
// 3. Create a variable called box2 of the Box structure type
struct Box box2;
// int box2Height, box2Width, box2Length;
int box2height ,box2width,box2length;
int totalVolume;
// 4. Input the height, width, lenght of box1 and box2
cout << "Enter Box 1 Height : ";
cin >> box1.height ;
cout << "Enter Box 1 Width : ";
cin >> box1.width ;
cout << "Enter Box 1 Length : ";
cin >> box1.lenght ;
cout << "Enter Box 2 Height : ";
cin >> box2.height ;
cout << "Enter Box 2 Width : ";
cin >> box2.width ;
cout << "Enter Box 2 Length : ";
cin >> box2.lenght ;
// 5. Replace the coding below to pass the Box type structure
totalVolume = volume( box1.height , box1.width ,box1.lenght )
+ volume(box2.height ,box2.width ,box2.lenght );
cout << "Volume of Box is " << totalVolume << endl;
return 0;
}
// Implement the functions here
int volume(int height, int width, int length)
{
int vol = height * width * length ;
return vol;
}