• Programming the strongest structure in java
    10 replies, posted
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.
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") [/code] 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.
Thanks! Yes that helped.
[QUOTE=Quark:;52889322]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") [/code] 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.[/QUOTE] Everything looks good except you have your indentation set at 8 spaces :) In python it should be 4 spaces [B]Edit:[/B] 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.
[QUOTE=brianosaur;52890003]Everything looks good except you have your indentation set at 8 spaces :) In python it should be 4 spaces [B]Edit:[/B] 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.[/QUOTE] 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
[QUOTE=BlkDucky;52890028]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[/QUOTE] No he's not: [url]https://www.python.org/dev/peps/pep-0008/#indentation[/url] [editline]19th November 2017[/editline] Also, tabs are discouraged: [url]https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces[/url]
[QUOTE=DrDevil;52905481]No he's not: [url]https://www.python.org/dev/peps/pep-0008/#indentation[/url] [editline]19th November 2017[/editline] Also, tabs are discouraged: [url]https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces[/url][/QUOTE] im not saying tabs aren't discouraged or that his tab width is wrong, you're missing the point
i don't even use python.. i just don't know java.
[QUOTE=Quark:;52913429]i don't even use python.. i just don't know java.[/QUOTE] That's my problem too, I've used other languages but completely new to Java
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.
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.
Sorry, you need to Log In to post a reply to this thread.