Write a program in java to find the perimeter of a rectangle, p = 2(length + breadth), taking length and breadth as inputs a) Using Function Argument b) Using Scanner Class
Answers
Answered by
6
import java.util.Scanner;
public class Perimeter
{
public static void main(String[] args)
{
int l, b, perimeter;
Scanner s = new Scanner(System.in);
System.out.print("Enter length of rectangle:");
l = s.nextInt();
System.out.print("Enter breadth of rectangle:");
b = s.nextInt();
perimeter = 2 * (l + b);
System.out.println("Perimeter of rectangle:"+perimeter);
}
}
Similar questions