Find Area Of The Rectangle Taking Width And Radius From The User | Java Programs

Output:

*** Area Of Rectangle ***

Enter the width of rectangle: 5
Enter the height of rectangle: 7
The Area Of Rectangle is: 35.0 sq units

Click Here For Java Online Compiler

Solution:

import java.util.Scanner;

class AreaOfRectangle {

    void findArea(float x, float y) {
        double area = x * y;
        System.out.println("The Area Of Rectangle is: " + area + " sq units");
    }

    public static void main(String args[]) {
        AreaOfRectangle area = new AreaOfRectangle();
        Scanner sc = new Scanner(System.in);
        System.out.println("*** Area Of Rectangle ***" + "\n");
        System.out.print("Enter the width of rectangle: ");
        int width = sc.nextInt();
        System.out.print("Enter the height of rectangle: ");
        int height = sc.nextInt();
        area.findArea(width, height);
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon