eclipse - Java code - area of a polygon -
i have code no compile errors, after come in sec number while running crashes on me :(
heres have:
import java.util.scanner; public class assignment536 { public static void main(string[] args) { scanner input = new scanner(system.in); system.out.println("enter number of sides: "); int numberofsides = input.nextint(); system.out.println("enter side: "); double side = input.nextint(); system.out.println("the area of polygon is: " +area(numberofsides, side)); input.close(); } public static double area(int n, double side) { double reply = (n*(side*side))*(4*(math.tan((math.pi*n)))); homecoming answer; } }
any help appreciated! give thanks you, sebastian
you should change:
final double side = input.nextint();
for
final double side = input.nextdouble();
if want read double.
java eclipse methods polygon area
No comments:
Post a Comment