I have created a Java class called Rectangle
that has the two instance variables (width & height) &
two instance methods (area and circumference) both method do not take parameters but
return double values. The area method returns area of rectangle (width * height) while
circumference returns (2*width+2*height). Then create Demo class with main method to test
the class Rectangle by instantiating 4 objects and prompts user to enter width and height for
each instance. Then print out the area and circumference for each instance.
I create two class and the first class is Rectangle :
public class Rectagle {
private double width;
private double height;
public double area() {
return width * height;
}
public double circumference() {
return 2*width+2*height;
}
}
and I create the second class Demo to Test the class :
import java.util.Scanner;
public class Demo {
public static void main(String []args){
Scanner console=new Scanner(System.in);
Rectagle R1=new Rectagle();
Rectagle R2=new Rectagle();
Rectagle R3=new Rectagle();
Rectagle R4=new Rectagle();
}
}
my problem , I don't understand this point " and prompts user to enter width and height for each instance. Then print out the area and circumference for each instance.