[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Java Programming

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 10
Thread images: 1

File: TriangleClassification.gif (5KB, 588x266px) Image search: [Google]
TriangleClassification.gif
5KB, 588x266px
Write a program that will prompt the user to input and integer that denotes sizes of sides of a triangle and determine the following:
a. determine if it forms a triangle or not;
b. if it forms a triangle, determine if it is and isosceles, equilateral or scalene.
c. if it doesn't form a triangle, then program should prompt the user that the inputs don't form a triangle.

Note: Consider the following guidelines:
a. isosceles triangle is described by having 2 sides equal.
b. equilateral triangle is described by having all 3 sides equal.
c. scalene triangle is described by having no sides equal.
d. to determine if the triangle really forms a triangle, the sum of 2 sides must be greater than the other side.
e. please provide comments of your program.

Please help me ,
>>
do your own homework

(or pay me)
>>
Please Help me. I beg you.
>>
>>18045452
I accept Bitcoin or Paypal
>>
>>18045421
Google is invented .. you know this, right ?

http://codereview.stackexchange.com/questions/18463/determining-triangle-type-from-three-integer-inputs

Remember to personalize it or get caught.
>>
-> stackoverflow triangle shit in java

Else, I suppose you have learned the basics, it is simply some if tests and printing
If it has 3 coordinates it is a triangle
If 3 segments (point b - point a is ab segment) are the same size..
Else if 2 segments have the same size.. Etc
>>
In how many hours time do you need it?
>>
[code]
//Here is a functional C version of what you need. Have fun porting it to Java :D
//Will span two posts, (too long).
//This example is freeware.
#include <stdio.h>

//Internal variables for Triangle class need to be somewhat like this.
struct triangle
{
int sides[3];
int isIsosceles;
int isEquilateral;
int isScalene;
int isTriangle;
};

//For internal usage only. Should be a class function.
int setTriangle(struct triangle *tri)
{
if( tri->sides[0] + tri->sides[1] == tri->sides[2] )
{
tri->isTriangle = 0;
return 0;
}
if( tri->sides[0] + tri->sides[2] == tri->sides[1] )
{
tri->isTriangle = 0;
return 0;
}
if( tri->sides[1] + tri->sides[2] == tri->sides[0] )
{
tri->isTriangle = 0;
return 0;
}

tri->isTriangle = 1;

return 0;
}

//For internal usage only. Should be a Class function.
int setIsosceles(struct triangle *tri)
{
int sameside=0;
if( tri->sides[0] == tri->sides[1] )
sameside++;
if( tri->sides[0] == tri->sides[2] )
sameside++;
if( tri->sides[1] == tri->sides[2] )
sameside++;

if( sameside == 1 && tri->isTriangle == 1 )
tri->isIsosceles = 1;
else
tri->isIsosceles = 0;
return 0;
}
[/code]
>>
[code]
//For internal usage only. Should be a Class function.
int setEquilateral(struct triangle *tri)
{
[/code]
if( ( tri->sides[0] == tri->sides[1] ) &&
( tri->sides[0] == tri->sides[2] ) )
{
tri->isEquilateral = 1;
return 0;
}

tri->isEquilateral = 0;
return 0;
}

//For internal usage only. Should be a Class function.
int setScalene(struct triangle *tri)
{
if( tri->sides[0] != tri->sides[1] &&
tri->sides[0] != tri->sides[2] &&
tri->sides[1] != tri->sides[2] )
{
tri->isScalene = 1;
return 0;
}

tri->isScalene = 0;
return 0;
}

//Run this when you have set the values for tri->sides[]
//This is how and what the Constructor should do.
int setupTriangle(struct triangle *tri)
{
setTriangle(tri); //Has to be done first.
setIsosceles(tri);
setEquilateral(tri);
setScalene(tri);
}


int main(void)
{
struct triangle tri;
int a;

//You may want to make a constructor that acceps the measurements of sides as variables.
for( a=0; a<3; a++ )
{
printf("Enter length of side %d of triangle: ", a);
scanf("%d", &tri.sides[a]);
}

setupTriangle(&tri);

printf("is triangle?\t %s\n", tri.isTriangle? "yes":"no");
printf("is isosceles?\t %s\n", tri.isIsosceles? "yes":"no");
printf("is equilateral?\t %s\n", tri.isEquilateral? "yes":"no");
printf("is scalene?\t %s\n", tri.isScalene? "yes":"no");
return 0;
}
>>
exactly how do you preserve whitespace here?
Thread posts: 10
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.