Computer Science, asked by mahibisht01, 1 year ago

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 amannishad0512p5zxh6
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 rakeshchennupati143
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:

  1. since the perimeter of rectangle is 2lb
  2. so i calculated 2 x 14.5 x 17.8
  3. and printed the value directly
  4. so it make less lines
  5. and it will allocates less space when compared to initializing variables and passing values to them

----- Hope this helps

Similar questions