Ask your own question, for FREE!
Computer Science 17 Online
OpenStudy (anonymous):

l4. Write a method that calculates the area of a rectangle by multiplying its length by its width. The length and width parameters are double values and the method returns a double.

OpenStudy (bibby):

What language is this? I can write down c++-ish pseudocode double calcArea(double len, double width) { //calculate area (l*w) //return that }

OpenStudy (anonymous):

java

OpenStudy (bibby):

I don't have a java compiler/IDE/whatever but you should at least know enough java to fix what's wrong public static double calcArea(double len, double width) { double area = len*width; return area; } public static double calcArea2(double len, double width) { return area = len*width; }

OpenStudy (bibby):

err the second one was supposed to be return len*width;

OpenStudy (liammeron):

In order to educate, instead of merely fix, can you explain what you don't understand? Are you unfamiliar with creating methods? Doubles? If you explain exactly what the problem is, we can help teach so that you have a deeper and better understanding of Java.

OpenStudy (blurbendy):

did you figure it out?

OpenStudy (anonymous):

Yes I figured it out a while ago. Thank you all so much!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!