Anda di halaman 1dari 1

x=Array.

new
y=Array.new
puts "This task is to calculate area of polygon"
puts "input how many point"
bil_point=gets.to_i
puts "Follow clockwise when you insert the coordinates"
i=0
while (i<bil_point)
print "input x#{i}"
x[i]=gets.to_f
print "input y#{i}"
y[i]=gets.to_f
i=i+1
end
i=0
sum=0
while (i<bil_point-1)
sum=sum+ (x[i+1]*y[i])-(x[i]*y[i+1])
i=i+1
end
puts "the area of polygon is;"
area=sum/2.0
print area
gets
puts "end"

Anda mungkin juga menyukai