Computer Science, asked by shree102, 10 months ago

Write a java program which displays perimeter of square and rectangle .​

Answers

Answered by Anonymous
2

import java.util.*;

public class Perimeter

{

public static void main(String args)

{

Scanner in=new Scanner(System.in);

float a,b,c,d,e;

System.out.println("Enter the side of the square");

a=in.nextFloat();

b=(4*a);

System.out.println("The perimeter of the square is="+b);

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

c=in.nextFloat();

System.out.println("Enter the breath of the rectangle");

d=in.nextFloat();

e=2*(c+d);

System.out.println("The perimeter of the rectangle is="+e);

}

}

Explanation:

*The perimeter of a square = 4*length of the side

*The perimeter of a square = 2*(length+breadth)

*We should accept the values in float data type because the value of the lengths of the side of the square and the length and breadth of the rectangle may can also be in decimal point.

For more java programmings follow the given links as I have solved earlier_

brainly.in/question/14335606

brainly.in/question/14323927

brainly.in/question/14370842

brainly.in/question/14395545

brainly.in/question/14809512

brainly.in/question/14809885

brainly.in/question/14840551

brainly.in/question/15125968

Similar questions