Advertisement
CoineTre

JF-LabMethods06.6. Calculate Rectangle Area

Feb 5th, 2021
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Lab6CalculateRectangleArea {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double width = Double.parseDouble(scanner.nextLine());
  7.         double length = Double.parseDouble(scanner.nextLine());
  8.         double area = getRectangleArea(width, length);
  9.         System.out.printf("%.0f",area);
  10.  
  11.     }
  12.  
  13.     private static double getRectangleArea(double width, double length) {
  14.         return width * length;
  15.     }
  16.  
  17. }
  18. //Create a method that calculates and returns the area of a rectangle by given width and length.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement