Overly Convoluted Homework Programs.

Published September 24, 2004
Advertisement
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);
}
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Music To My Ears

1742 views

Getting There...

1998 views

Guess Chess

1896 views

iPhone JetLag

1847 views

iPhone JetLag

1690 views
Advertisement