write a program to enter the length and bredth of a rectangle. find the are perimeter and diagnal of rectangle.
using stream reader
Answers
Answered by
1
Answer:
public class Rectangle {
public static void main(String[] args) {
float length, width, area, perimeter;
Scanner in = new Scanner(System.in);
// Input length and width of rectangle
System.out.print("Enter length of rectangle: ");
length = in.nextFloat();
System.out.print("Enter width of rectangle: ");
width = in.nextFloat();
perimeter = 2 * (length + width);
area = length * width;
System.out.println("Perimeter of rectangle is " + perimeter + " units.");
System.out.println("Area of rectangle is " + area + " sq. units.");
Similar questions