Java Online Compiler
Example: Java program to find the area of a rectangle
C
C++
C#
Java
Python
PHP
Main.java
STDIN
Run
// Java program to find the area of a rectangle import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Enter the length & width of the rectangle::\n"); // Reading data using readLine float l = in.nextFloat(); float w = in.nextFloat(); float a; /* Calculate area of rectangle */ a = l * w; System.out.print("\n"); System.out.println("Area of rectangle = " + a + " units"); } }
5 7
Output
Clear
ADVERTISEMENTS