write a program in java to find the perimeter of a rectangle with lenghth 14.5 cm and breadth 17.8 cm.
Anonymous:
hy
Answers
Answered by
3
import java.util.*;
class Perimeter
{
public static void main (String args[ ] )
{
double length=14.5,breadth=17.8, perimeter=0.0d;
perimeter=2*(length*breadth);
System.out.println("Perimeter of rectangle is "+perimeter);
}
}
I m first to answer,mark me brainlest.
And follow me for more java related doubts.
I am java lover and learner.
Answered by
0
Program:
import java.io.*;
public class Main{
public static void main(String args[]){
System.out.println("Perimeter of the rectangle with lenght 14.5cm and breadth as 17.8cm is : "+(2*14.5*17.8)+"cm.");
}
}
Output:
Perimeter of the rectangle with lenght 14.5cm and breadth as 17.8cm is : 516.2cm.
Explanation:
- since the perimeter of rectangle is 2lb
- so i calculated 2 x 14.5 x 17.8
- and printed the value directly
- so it make less lines
- and it will allocates less space when compared to initializing variables and passing values to them
----- Hope this helps
Similar questions