Results 1 to 7 of 7
Thread: Help
 11292010, 12:17 AM #1
Help
Doing an interesting problem that I've found on the net, I'm gonna give it a shot. Can you guys do it as well? I wanna compare my code to yours. Especially if I don't get the code right, I wanna find out and learn where I went wrong.
Triangles can be classified in a number of ways by considering the relative sizes of either their
sides or their angles.
Side Classifications:
1. equilateral – all sides are equal
2. isosceles – exactly two sides are equal
3. scalene – no sides are equal
Side classifications are done by comparing the length of the three sides of the triangle.
Angle Classifications:
1. right – the largest angle is a right angle (i.e., 90°)
2. acute – the largest angle is less than a right angle
3. obtuse – the largest angle is greater than a right angle
If the three sides of a triangle are known, the Pythagorean Theorem can be used to classify the
triangle as right, obtuse, or acute.
Recall: The Pythagorean Theorem states that, in a right triangle, the square of the largest side is
equal to the sum of the squares of the other two sides. As an equation,
c2=a2b2
If the triangle is not a right triangle, this relationship can still be used to determine if the triangle is
acute or obtuse.
Problem Statement
Write a program that will read an arbitrary number of sets of triangle sides using only integer
values. The program should:
1. Prompt the user for sets of numbers and process them until the user submits the numbers
0 0 0, which will terminate the program.
2. For each set of three numbers, the program should print the values read.
3. For each set of three numbers, the program should decide if the numbers represent the
sides of a valid triangle.
4. If the numbers could not represent a valid triangle, display an appropriate error message.
5. If the numbers are valid, the program should determine, and display, the:
(a) side classification of the triangle – equilateral, isosceles, or scalene
(b) angle classification of the triangle – right, acute, or obtuse
ICS3x Assignment – Methods – Triangle Classification Nov 24, 2010
Sample Input & Output
Input from the user is indicated by bolded text.
Provide three side lengths – 0 0 0 to terminate.
3
5
4
3 5 4 Triangle possible: scalene and right.
Provide three side lengths – 0 0 0 to terminate.
5
2
5
5 2 5 Triangle possible: isosceles and acute.
Provide three side lengths – 0 0 0 to terminate.
7
1
2
7 1 2 Triangle cannot be formed.
Provide three side lengths – 0 0 0 to terminate.
0
0
0
0 0 0 Program was terminated by user.
(You can only use input/output, calculations, variables, decisions, and loops)

Last edited by Fubarable; 11292010 at 12:45 AM.
 11292010, 01:13 AM #3
Ehh, this is pretty tough to be honest. All I have so far is:
class triangles
{
public static void main (String args [])
{
Yeah I know, pretty sad. :( Anyone wanna explain how I should begin going by this? I just need a step in the right direction.Last edited by Kael; 11292010 at 01:19 AM.
 11292010, 03:45 AM #4Member
 Join Date
 Nov 2010
 Posts
 90
 Rep Power
 0
@ Furbable, you are 100% correct.
this is for Brookfield Highschool Grade 11 Computer Studies ICS 3C/3U Class.
this is his first assignment
Mr. Sweeney's Course Wiki / ICS3U
@Kael, For lying about an assignment for School and saying you found it on the net you shall recieve no help at all.
you May have recieved some help if you were up front but i believe the folks here would not touch this at all now
 11292010, 06:01 AM #5
 11292010, 11:52 AM #6
Hmm, I assumed that if I was up front, I wouldn't get any help at all. But I respect your decision regardless.
Yes, I'm aware of this. Believe it or not, I'm actually trying to learn this. This class is a lot tougher than my math, bio, and chem classes.
Anyways, after watching several youtube videos tutorials on if statements and looping, I've made some progress on this, though I still don't understand what the question means by terminating. I'm gonna look into that more by googling.
class Triassign
{
public static void main (String [] args)
{
int number1, number2, number3;
{
System.out.println("You must enter 3 numbers and you will be told if it is" +
" equaliteral, scalene, or isoceles, along with if" +
"it is acute, obtuse or a right.");
System.out.println("Insert your first number");
number1=In.getInt();
System.out.println("Insert your second number");
number2=In.getInt();
System.out.println("Insert your third number");
number3=In.getInt();
{
while (number1==0 &&number2==0 && number3==0);
{
if (number1==number2 && number2==number3 && number1 ==number3)
{
System.out.println("This is an equalateral triangle.");
System.out.println("Are you done? Click yes, and then put 000 to end it.");
say yes = In.getString();Last edited by Kael; 11292010 at 12:30 PM.

It's quite the opposite. We will help folks with homework if they're honest about it and if they demonstrate effort.
Yes, I'm aware of this. Believe it or not, I'm actually trying to learn this. This class is a lot tougher than my math, bio, and chem classes.
...I still don't understand what the question means by terminating.
[quote
Here's where I'm stuck. Im trying to make it pop out in the interactions tab to make it say yes. Since it's not a number but a word, I put:
yet that doesn't work? Why can I use the word number above perfectly but not these words?[/QUOTE]
I'm not 100% sure what you're trying to do, and I'm not sure what your in variable is as it doesn't look to be a Scanner object.
Also, please use code tags with code, not quote tags.
Bookmarks