The area of a rectangle can be computed using the following formula:                                                  area = width * height;   Write a method that returns the area of a rectangle using the following header:   public static double getArea(double width, double height) Write a main method that prompts the user to enter the width and height of a rectangle and displays its area.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

The area of a rectangle can be computed using the following formula:

                                                 area = width * height;

 

Write a method that returns the area of a rectangle using the following header:

  public static double getArea(double width, double height)

Write a main method that prompts the user to enter the width and height of a rectangle and displays its area.

 

Input  example:

1.2

3.4

Output example:

The area of the rectangle is 4.08

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT