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
|
#include <iostream>
using namespace std;
int main()
{
int area, triangle_height, wall_height, triangle_width;
// This first line establishes what needs to be done.//
cout << "Hey, user. I need some measurements to calculate an area. Can you help me out? You can?! Thanks!\n";
//This one asks for the height of the wall on the house, specifying that the user need not enter the height including the triangle.//
cout << "Okay, to start, what's the height of the wall on the A-frame house? JUST the wall, not the whole house.";
cin >> wall_height;
//Same here, only thing needed is the triangle width (aka the wall width since it lines up with the triangle perfectly.)//
cout << "Alright cool, thanks! Now, what's the triangle width?";
cin >> triangle_width;
//Last line of input simply asks for the triangle height.//
cout << "Awesome, just one more. Lastly, what's the triangle height? ";
cin >> triangle_height;
//Once the system knows the integer values for all three variables, it does the following equation.//
area = triangle_height * triangle_width / 2 + wall_height * triangle_width;
//This simply calculates the 1/2bh area of the triangle and adds it to the length * width of the rectangle i.e. the triangle width, since they're interchangeable.//
cout << "Thanks for your help! The area of the A-frame house is approximately " << area << " square feet.\n";
return 0;
}
|