 • entries
292
557
• views
155229

Overly Convoluted Homework Programs.

If you've ever taken a look at the public board on Kasamba, you've seen lots of homework questions. I found one, and decided to make an overly complex solution to a rather simple problem. However, the guy yanked his question before I got a chance to post it, so here it is:

#include
#include

template
class triangle_area_calculator
{
private:
client_t a,b,c;
public:
triangle_area_calculator(client_t a,client_t b,client_t c){this->a=a;this->b=b;this->c=c;}
bool is_triangle(){client_t s=(a+b+c)/2;return(((s-a)*(s-b)*(s-c))>0);}
client_t get_area(){client_t s=(a+b+c)/2;return(sqrt(s*(s-a)*(s-b)*(s-c)));}
};

int main(int argc,char* argv[])
{
std::cout<<"Calculate an area of a triangle from its three sides."< std::cout<<"Please enter the three lengths, separated by spaces."< double a,b,c;
std::cin>>a>>b>>c;
std::cout< triangle_area_calculator calculator(a,b,c);
if(calculator.is_triangle())
{
std::cout<<"The area of the triangle is "< }
else
{
std::cout<<"Those are not valid lengths for the three sides of a triangle."< }
return(0);
}

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account