1 Replies - 1554 Views - Last Post: 15 November 2013 - 03:22 PM

#1 atik97   User is offline

  • ???
  • member icon

Reputation: 144
  • View blog
  • Posts: 715
  • Joined: 16-September 08

Angle Conversion

Posted 12 April 2009 - 02:02 AM

Description: Converts an angle from radian to degree and vice versa.
def d2r()
  puts "Enter the value of angle in degree"
  t=gets.chomp.to_f
  #corresponding value in radian
  r=(3.14*t)/180
  puts "The value of given angle in radian is "+r.to_s
end

def r2d()
  puts "Enter the value of angle in radian:"
  r=gets.chomp.to_f
  #corresponding value in degree
  t=(180*r)/3.14
  puts "The value of given angle in degree is " +t.to_s
end


Is This A Good Question/Topic? 0
  • +

Replies To: Angle Conversion

#2 Lemur   User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1453
  • View blog
  • Posts: 3,633
  • Joined: 28-November 09

Re: Angle Conversion

Posted 15 November 2013 - 03:22 PM

def to_radians(t) (3.14*t)/180 end def to_degrees® (180*r)/3.14 end Cleaner
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1