wap in java find the area and rectangle by using the value accept from user
Answers
Answered by
1
- import java. util. Scanner; class AreaOfRectangle.
- public static void main(String args[]) {
- Scanner s= new Scanner(System. in);
- double l= s. nextDouble(); System. out. println("Enter the breadth:");
- double b= s. nextDouble();
- System. out. println("Area of Rectangle is: " + area); }
Answered by
0
Answer:
import java.util.Scanner;
class Area
{
public static void main(String[] args)
{
//Declaration
Scanner input = new Scanner(System.in);
double area;
double length, breadth;
//Prompt and accept length and breadth of rectangle from user
System.out.println(“Enter the length and the breadth of the rectangle: ”);
length = input.nextDouble();
breadth = input.nextDouble();
//Calculate the area of the rectangle
area = length * breadth;
//Display the result
System.out.println(“The area of the rectangle is = ” + area);
}
}
Similar questions