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.
What language is this? I can write down c++-ish pseudocode double calcArea(double len, double width) { //calculate area (l*w) //return that }
java
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; }
err the second one was supposed to be return len*width;
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.
did you figure it out?
Yes I figured it out a while ago. Thank you all so much!
Join our real-time social learning platform and learn together with your friends!