Recman 6Le lenght inte width int t set lenght length in t t
Recman 6Le lenght inte width int t set lenght (length in t) t set width (width, int t get lenght int et width int t find Area lenght int, dth in int ublic class Red angle or instance ll set and get method ll hel or auxilli, any method per blic int find int lenght, intdodth retur lenght width
Solution
import java.util.Scanner;
public class Rectangle
{
int length;
int width;
void setDimenstion(int l, int w)
{
length=l;
width=w;
}
void getDimension()
{
Scanner in= new Scanner(System.in);
System.out.println(\"Please enter length of a rectangle\");
length=in.nextInt(); //Enter 100
System.out.println(\"Please enter width of a rectangle\");
width=in.nextInt(); //enter 80
}
public int findArea(int length.int width)
{
return length*width;
}
public static void main(String[] args) {
int area;
Rectangle r=new Rectangle();
r.getDimension();
r.setDimension(length,width);
area=r.findArea(100,80);
System.out.println(\"Area=\"+area);
}
