Computer Science, asked by tirkeyk387, 7 months ago

Write a Java Program to accept the length and breadth of a rectangle and find its perimeter (output also plzzzz)​

Answers

Answered by sanjeevani111982
3

// Java program to find the perimeter of a rectangle

import java.util.Scanner;

public class Demo {

public static void main(String[] args)

{

Scanner in = new Scanner(System.in);

System.out.println("Enter the length & width of the rectangle::\n");

// Reading data using readLine

float l = in.nextFloat();

float w = in.nextFloat();

float p;

/* Calculate perimeter of rectangle */

p = 2 * (l + w);

System.out.print("\n");

System.out.println("The Perimeter of rectangle = " + p + " units");

}

}

output:

Output:

$ javac Area_Perimeter .java

$ java Area_Perimeter

Enter length of rectangle:4

Enter breadth of rectangle:5

Perimeter of rectangle:18

Area of rectangle:20

Answered by ıtʑFᴇᴇʟɓᴇãᴛ
32

\mathtt{\huge{\underline{\red{Raw\:Programme:-}}}}

int, java.util.Scanner;

class PerimeterOfRectangle

{

public static void main(String [])

{

Scanner s= new Scanner(System.in);

System.out.println("Enter the length of the Rectangle:");

double l = s.nextDouble();

System.out.println("Enter the width of the Rectangle:");

double b= s.nextDouble();

double perimeter=2*(l+b);

System.out.println("Orignal perimeter: " + perimeter);

}

}

\mathtt{\huge{\underline{\pink{Programme:-}}}}

int, java.util.Scanner;

class PerimeterOfRectangle

{

public static void main(String [])

{

Scanner s= new Scanner(System.in);

System.out.println("8:");

double l = s.nextDouble();

System.out.println("6:");

double b= s.nextDouble();

double perimeter=2*(8+6);

System.out.println(" 28" );

}

}

\mathtt{\huge{\underline{\green{Output:-}}}}

 \setlength{\unitlength}{0.25cm}\begin{picture}(5,5)\thicklines\multiput(0,0)(24,0){2}{\line(0,1){10}}\multiput(0,0)(0,10){2}{\line(1,0){24}}\put(10,-2){\sf{8\ cm}}\put(25,3){\sf{6\ cm}}\end{picture}

  • Length = 8

  • Breadth = 6

Perimetere = 2 ( l + b )

= 2 ( 8 + 6)

= 2 × 14

= 28

Availble on Brainly web

______________________________________

Similar questions