Write a program in Java to find the area of rectangle where length=4.4 and width=5.5. (Area
of Rectangle = l*b).
answer
Answers
Answered by
3
public class Main{
public static void main(String args[])
{
float l=4.4;
float b=5.5;
System.out.println("Area of rectangle="+l*b);
}
}
Answered by
2
Required Answer:-
Question:
- Write a program in Java to find the area of the rectangle whose length = 4.4 and width=5.5.
Solution:
Here comes the program.
- public class Area {
- public static void main(String[] args) {
- float l=4.4f, w=5.5f, a=l*w;
- System.out.println("Length: "+l);
- System.out.println("Width: "+w);
- System.out.println("Area: "+a);
- }
- }
Explanation:
- Line 1: Creates the area class.
- Line 2: Contains main() method. It is the starting point of the execution of the program.
- Line 3: Declares the length, breadth and area. Area is calculated by formula, a = lb.
- Line 4: Length is displayed.
- Line 5: Breadth is displayed.
- Line 6: Area is displayed.
- Line 7: End of main().
- Line 8: End of class.
Refer to the attachment for output ☑.
Attachments:
Similar questions