1. Post #1

    November 2017
    3 Posts
    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. Post #2
    Gold Member
    Quark:'s Avatar
    January 2011
    5,759 Posts
    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.
    Reply With Quote Edit / Delete Reply Windows 10 Chrome Show Events Programming King Programming King x 3Friendly Friendly x 1 (list)

  3. Post #3

    November 2017
    3 Posts
    Thanks! Yes that helped.
    Reply With Quote Edit / Delete Reply Windows 10 Chrome Show Events Friendly Friendly x 1 (list)

  4. Post #4
    faster than stupid, but still slower than everybody else

    June 2010
    3,149 Posts
    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.
    Reply With Quote Edit / Delete Reply Mac Chrome Show Events Dumb x 22Agree x 2Programming King x 2Informative x 1Funny x 1 (list)

  5. Post #5
    Gold Member
    BlkDucky's Avatar
    May 2008
    6,166 Posts
    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
    Reply With Quote Edit / Delete Reply Windows 10 Chrome Show Events Zing Zing x 10Funny Funny x 2Disagree Disagree x 1 (list)

  6. Post #6
    www.bff-hab.de
    DrDevil's Avatar
    May 2006
    3,307 Posts
    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
    Reply With Quote Edit / Delete Reply Linux Chrome Show Events Agree Agree x 3Dumb Dumb x 3 (list)

  7. Post #7
    Gold Member
    BlkDucky's Avatar
    May 2008
    6,166 Posts
    im not saying tabs aren't discouraged or that his tab width is wrong, you're missing the point
    Reply With Quote Edit / Delete Reply Windows 10 Chrome Show Events Informative Informative x 1Programming King Programming King x 1 (list)

  8. Post #8
    Gold Member
    Quark:'s Avatar
    January 2011
    5,759 Posts
    i don't even use python.. i just don't know java.

  9. Post #9

    November 2017
    3 Posts
    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
    Reply With Quote Edit / Delete Reply Windows 10 Chrome Show Events Programming King Programming King x 1 (list)

  10. Post #10
    Gold Member
    343N's Avatar
    December 2008
    8,464 Posts
    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.
    Reply With Quote Edit / Delete Reply Android Unofficial Facepunch Android App Show Events Agree Agree x 6 (list)

  11. Post #11
    faster than stupid, but still slower than everybody else

    June 2010
    3,149 Posts
    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.
    Reply With Quote Edit / Delete Reply Mac Chrome Show Events Optimistic Optimistic x 2Dumb Dumb x 1Disagree Disagree x 1 (list)