1. Post #1

    November 2017
    2 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,601 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 2Friendly Friendly x 1 (list)

  3. Post #3

    November 2017
    2 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,142 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 13Funny x 1Agree x 1Friendly x 1Programming King x 1 (list)

  5. Post #5
    Gold Member
    BlkDucky's Avatar
    May 2008
    6,162 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 7Funny Funny x 1 (list)