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
|
// Struct-Volume.cpp : Defines the entry point for the console application.
//
#include <iostream>
struct Distance
{
float feet;
float inches;
};
struct Volume
{
Distance width;
Distance height;
Distance depth;
};
float area(float, float, float, float, float, float);
int main()
{
Volume v1;
std::cout << "Please provide how deep is room" << std::endl;
std::cout << "Feet: ";
std::cin >> v1.depth.feet;
std::cout << "Inches: ";
std::cin >> v1.depth.inches;
std::cout << std::endl;
std::cout << "Please provide how wide is room" << std::endl;
std::cout << "Feet: ";
std::cin >> v1.width.feet;
std::cout << "Inches: ";
std::cin >> v1.width.inches;
std::cout << std::endl;
std::cout << "Please provide how high is room" << std::endl;
std::cout << "Feet: ";
std::cin >> v1.height.feet;
std::cout << "Inches: ";
std::cin >> v1.height.inches;
std::cout << std::endl;
float depth_Feet = v1.depth.feet;
float depthInch = v1.depth.inches;
float widthFeet = v1.width.feet;
float widthInch = v1.width.inches;
float heightFeet = v1.height.feet;
float heightInches = v1.height.inches;
float cubic = area(float depth_Feet, float depthInches, float widthFeet, float widthInches, float heightFeet, float heightInches);
std::cout << "Qubic area of the room is: " << cubic << std::endl;
return 0;
}
float area(float depthFeet_, float depthInches_, float widthFeet_, float widthInches_, float heightFeet_, float heightInches_)
{
float cubicD = depthFeet_ + depthInches_ / 12;
float cubicW = widthFeet_ + widthInches_ / 12;
float cubicH = heightFeet_ + heightInches_ / 12;
float cubic_ = cubicD * cubicW * cubicH;
return cubic_;
}
|