write a program in java to initialize 2 values and find area of a rectangle.
Answers
Algorithm :-
Step 1: Start.
Step 2: Declare three variables of type double l, b and a to store the length, breadth and area of the rectangle.
Step 3: Calculate the area of the rectangle and Print it.
Step 4: End.
Program :-
import java.util.Scanner; \\importing package
class d \\class declaration
{
public static void main(String args[])
\\main()method declaration
{
System.out.println("Enter the length and breadth of a rectangle");
double l, b, a; \\variable description
Scanner sc=new Scanner(System.in); \\input object creation
l = sc.nextDouble();
b = sc.nextDouble();
a = l*b;
System.out.println("Area of the rectangle is - " + a);
}
}
Output :- in the attachment.
Glossary :-