Reply Subscribe

1. Hey guys, I am new to Java but not new to programming. Just wondering how I would create a program where it inputs the lengths of the 3 sides of a triangle, then prints out if the triangle is equilateral, scalene, or isosceles depending on the answers.

2. It should be fairly easy. Here's some Python to give you the basic idea.
Code:
```print("Input lengths of the triangle sides: ")
x = int(input("x: "))
y = int(input("y: "))
z = int(input("z: "))

if x == y == z:
print("Equilateral triangle")
elif x != y != z:
print("Scalene triangle")
else:
print("isosceles triangle")```
If it is an equilateral triangle, all of the sides are equal in length. If it is a scalene triangle, none of the sides are equal in length. If it is an isosceles triangle, two of the sides are equal in length.

Hope this helps.
Programming King x 3 Friendly x 1 (list)

3. Thanks! Yes that helped.
Friendly x 1 (list)

4. It should be fairly easy. Here's some Python to give you the basic idea.
Code:
```print("Input lengths of the triangle sides: ")
x = int(input("x: "))
y = int(input("y: "))
z = int(input("z: "))

if x == y == z:
print("Equilateral triangle")
elif x != y != z:
print("Scalene triangle")
else:
print("isosceles triangle")```
If it is an equilateral triangle, all of the sides are equal in length. If it is a scalene triangle, none of the sides are equal in length. If it is an isosceles triangle, two of the sides are equal in length.

Hope this helps.
Everything looks good except you have your indentation set at 8 spaces :)

In python it should be 4 spaces

Edit:

If you give me boxes its obvious you dont code in python. Code style is important and in python the standard is set by PEP8 currently.
x 22 x 2 x 2 x 1 x 1 (list)

5. Everything looks good except you have your indentation set at 8 spaces :)

In python it should be 4 spaces

Edit:

If you give me boxes its obvious you dont code in python. Code style is important and in python the standard is set by PEP8 currently.
im giving you boxes because thats 1 tab character and it's up to the browser how to render it, pal :))

edit: wait no it's not but you're still wrong lmao
Zing x 10 Funny x 2 Disagree x 1 (list)

6. im giving you boxes because thats 1 tab character and it's up to the browser how to render it, pal :))

edit: wait no it's not but you're still wrong lmao
No he's not: https://www.python.org/dev/peps/pep-0008/#indentation

Edited:

Also, tabs are discouraged: https://www.python.org/dev/peps/pep-...tabs-or-spaces
Agree x 3 Dumb x 3 (list)

7. im not saying tabs aren't discouraged or that his tab width is wrong, you're missing the point
Informative x 1 Programming King x 1 (list)

8. i don't even use python.. i just don't know java.

9. i don't even use python.. i just don't know java.
That's my problem too, I've used other languages but completely new to Java
Programming King x 1 (list)

10. I love it when beginners post about a small issue and the people who know what they're doing between argue.. Not a very good first impression, and for me personally was pretty discouraging.
Agree x 6 (list)

11. All I was saying is that there's python conventions. I didn't mean for this to be some argument, which is why I haven't replied. It's just a good thing to know about if you're coding in python, and I was just trying to share some knowledge...

I'm still not quite sure what the exact point BlkDucky was trying to make.
Optimistic x 2 Dumb x 1 Disagree x 1 (list)