Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

my library > cse110 - principles of programming home > 7.18: genes gree…

Question

my library > cse110 - principles of programming home > 7.18: genes green part 1 - area of rectangle (individual assignment) this method should have two double parameters named width and height. when called, this method should compute and then return the area (as a double) of a rectangle with the given width and height. here is some code to start with: public static double areaofrectangle(<add required parameters here>) { double area = <compute the area here> return area; } examples areaofrectangle(3.0, 5.0) should return the value 15.0 areaofrectangle(8.0, 3.0) should return the value 24.0 areaofrectangle(7.5, 5.5) should return the value 41.25 helpful hints: - you may wish to write some additional code (in the main method) to test your method - there should be no print (or println or printf) statements in your areaofrectangle method - there should be no calls to any scanner methods in your areaofrectangle method need help? additional help resources are available by clicking on the words
eed help?\ at the bottom of this page and search for help or ask a question. open new tab dock run genesgreen.java history tutorial

Explanation:

Step1: Add width/height parameters

public static double areaOfRectangle(double width, double height) {

Step2: Calculate rectangle area

<Expression>
$\text{area} = \text{width} \times \text{height}$
</Expression>

double area = width * height;

Step3: Return computed area

return area;
}

Answer:

public static double areaOfRectangle(double width, double height) {
    double area = width * height;
    return area;
}