Computer Science, asked by aakashharwani06, 19 days ago

Write a java program to print the area of a rectangle by creating a class named
'Area' having two functions.
First function named as 'setDim' takes the length and breadth of the rectangle
as parameters and the second function named as 'getArea' returns the area of
the rectangle.
Take the input from the user using Joption Pane class.

Answers

Answered by aadak2307
0

Answer:

Your java program :-

public class Area{

int length,breadth;

Area(int l, int b){

length = l;

breadth = b;

}

public int setDim(){

int results = length * breadth;

return results;

}

public void getArea(){

System.out.println("Area = " + setDim());

}

public static void main(String []args){

Area x =new Area(6,5);

x.getArea();

}

}

Explanation:

Hope I am correct and it helps you :)

Similar questions