-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccept-input-display-volume.cpp
More file actions
63 lines (47 loc) · 1.37 KB
/
Accept-input-display-volume.cpp
File metadata and controls
63 lines (47 loc) · 1.37 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
55
56
57
58
59
60
61
62
63
//CSC 160 March 4 in class excercise 2
//Author: Larsen J Close Most recent changes: 3/4/16
#include <iostream> // preprocessor directive
#include <iomanip> // needed for most manipulators
using namespace std; // using directive
void getData(double& l, double& w);
void getData(double& l, double& w, double& h);
int main ( void )
{
double l, w, h;
cout << "Enter the length and width of a rectangle (inches): \n";
getData(l, w);
cout << "Rectangle area = " << l*w << " square inches\n\n";
cout << "Enter the length, width, and height of a box (inches): \n";
getData(l, w, h);
cout << "Box volume = " << l*w*h << " cubic inches\n";
system ("pause");
return 0;
} //end main ( )
void getData(double& l, double& w)
{
cout << "Length: ";
cin >> l;
cout << "Width: ";
cin >> w;
}
void getData(double& l, double& w, double& h)
{
cout << "Length: ";
cin >> l;
cout << "Width: ";
cin >> w;
cout << "Height: ";
cin >> h;
}
/* Output of above program
Enter the length and width of a rectangle (inches):
Length: 20
Width: 10
Rectangle area = 200 square inches
Enter the length, width, and height of a box (inches):
Length: 30
Width: 20
Height: 10
Box volume = 6000 cubic inches
Press any key to continue . . .
*/