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 64 65 66 67 68 69 70 71 72 73 74 75 76
|
#include <iostream>
using namespace std;
// Function name: get_data
// Purpose: Finding perimeter, volume, area of a room
// Input(s):
// Output(s): perimeter, volume, area
void get_data(float& perimeter, float& volume, float& area, float& length, float& width, float&height);
// Function name: Calculation
// Purpose: To find the perimeter, volume, and area of the room
// Input(s): length, width, height
// Output(s): perimeter, volume, area
void calculation(float perimeter, float volume, float area, float length, float width, float height);
// Function name: Output
// Purpose: Display perimeter, volume, and area of a room
// Input(s): perimeter, volume, area, length, width, height
// Output(s):
void output(float perimeter, float volume, float area, float length, float width, float height);
int main()
{
float perimeter, volume, area, length, width, height;
get_data(perimeter, volume, area, length, width, height);
calculation(perimeter, volume, area, length, width, height);
output(perimeter, volume, area, length, width, height);
system("pause");
return 0;
}
void get_data(float& perimeter, float& volume, float& area, float& length,float& width, float& height)
{
// user input section
cout << "Press return after entering a number" << endl;
cout << "Please enter the length of the room" << endl;
cin >> length;
cout << "Please enter the width of the room" << endl;
cin >> width;
cout << "Please enter the height of the room" << endl;
cin >> height;
}
void calculation(float perimeter, float volume, float area, float length, float width, float height)
{
// calculation section
perimeter = (height * 2) + (width * 2);
volume = length * width * height;
area = length * width;
}
void output(float perimeter, float volume, float area, float length, float width, float height)
{
// output section
cout << "the perimeter is " << perimeter << " meters" << endl;
cout << "the volume is " << volume << " cu. meters" << endl;
cout << "the area is " << area << " sq. meters" << endl;
}
|