What is wrong with this program?

I don’t understand what is wrong with this program. It gives an error:
‘findarea’ undefined local variable or method ‘area_of_triangle’
Both ‘findarea’ and ‘area_of_triangle’ are clearly defined.

On Aug 6, 11:51 pm, Prateek A. [email protected] wrote:

I don’t understand what is wrong with this program. It gives an error:
‘findarea’ undefined local variable or method ‘area_of_triangle’
Both ‘findarea’ and ‘area_of_triangle’ are clearly defined.

Attachments:http://www.ruby-forum.com/attachment/3933/Q3a1.rb


Posted viahttp://www.ruby-forum.com/.

Prateek,

You post alot of basic troubleshooting questions on the list. This
really is something you need to learn to do on your own when
programming, as no one gets their code right the first time through
the keyboard.

But for this, a simple Ctrl+F through your own code will give you the
answer.

Hi
two errors there

1 area_of_triange=Math.sqrt(s*(s-side_a)(s-side_b)(s-side_c))
spelling mistake in area_of_triange
2 return area
area is not defined

Sijo

On Aug 7, 1:33 am, Sijo Kg [email protected] wrote:

Posted viahttp://www.ruby-forum.com/.
One of my friends during conversation:

what i have learned from my time at hms both as a tech and as a mentor
that getting answers is a drug. you get addicted to it. if you find
some venue through which you happen to get a bunch of answers, be it a
forum or list or nate coffield, you will abuse it until it turns on you

On Aug 6, 2009, at 21:10, pharrington wrote:

Prateek,

You post alot of basic troubleshooting questions on the list. This
really is something you need to learn to do on your own when
programming, as no one gets their code right the first time through
the keyboard.

But for this, a simple Ctrl+F through your own code will give you the
answer.

Also, seems to be homework based on the filename.

pharrington wrote:

what i have learned from my time at hms both as a tech and as a mentor
that getting answers is a drug. you get addicted to it. if you find
some venue through which you happen to get a bunch of answers, be it a
forum or list or nate coffield, you will abuse it until it turns on you

Ya ya… I can quit any time … just give me some more answers please…

ilan

Hey,

There are couple of things to be mended in the function “findarea”.

They are

(i) “area_of_segment=(4.0/3)*area_of_triangle” But in the prev line,
you have declared the variable as “area_of_triange”. “L(l) is
missing.”

(ii) You’re returning the variable “area” from the function to the
main block. But there is no such variable in the function. Guess it
has to be “area_of_segment”.

This should work now.

  • Balbao.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs