Monday, June 14, 2021

Java program to print the area and perimeter of a rectangle (Java) (173)

package com.company;
import java.util.Scanner;
public class Program10 {
public static void main(String[] args) {
System.out.println("please enter the length of a rectangle:");
Scanner put=new Scanner(System.in);
float len=put.nextFloat();
System.out.println("please enter the width of the rectangle:");
float wid=put.nextFloat();
double area=2*len+2*wid;
System.out.println("the area of the rectangle is:");
System.out.println(area);
double peri=len*wid;
System.out.println("the perimeter of the rectangle is: ");
System.out.println(peri);
}
}

No comments:

Post a Comment