← Unit 1 · all exercises
Saved in this browser only

Area of a rectangle

Write a method that takes the width and height of a rectangle and returns its area.

int area(int width, int height)

Solution.java
Loading editor…
Results

Examples

  • area(3, 4) → 12a 3 by 4 rectangle
  • area(5, 5) → 25a square is a rectangle too

There are also 4 hidden tests you can't see. Solve the problem, not the examples.