Question: use the information above to write a code for experiment 4 Experiment #4: Type the following code into the main method of Experiment_4 and try

 use the information above to write a code for experiment 4
Experiment #4: Type the following code into the main method of Experiment_4
and try to run the main method. You may have to selectively
use the information above to write a code for experiment 4
comment out" portions of the code in order to test cach statement.

Experiment #4: Type the following code into the main method of Experiment_4 and try to run the main method. You may have to selectively comment out" portions of the code in order to test cach statement. Shape s; Rectangle r = new Rectangle ( 10, 20); Circle c = new Circle( 2, "Blue"); 5- r; System.out.println( r.getColor()); System.out.println( s.getColor() 0; W Statement #1 // Statement #2 System.out.println(s.getWidth(); W/ Statement #3 System.out.println( ((Rectangle) s).getWidth() ); // Statement #4 Sci System.out.println( ((Rectangle) s).getWidth() ); // Statement *5 nce (20-21) - INITIAL TEMPLATE Rectangle x Compile Undo Cut Copy Paste Find... Close Source Code /** * Class Rectangle represents a rectangle of given color */ public class Rectangle { private double 1; private double w; private String color; public Rectangle() public Rectangle( double 1, double w) public void setWidth( double w) public void setLength( double 11) public double getWidth() public double getLength() public void setColor( String c) public String getColor() public double getArea() { 1=0; w=0; color="Blue";} { this. l = 1; this.w = w; color="Blue" : { this.W = W; } { this. 1 1; > { return w; > { return 1;) { color = c;) { return color; } { return l*w; } public String toString() { return String.format("%s Rectangle size=(%.2f by %.2f)", color, 1, w); } Circle X Compile Undo Cut Copy Paste Find... Close Source Code /** * Class Circle - represents a circle of a given color. */ public class Circle { private double r; private String color; 21 21 mt mt public Circle(String c) { color = c; r=0; } public Circle( double ri, String c) { color = c; r = r1;} public void setRadius double r1) { r = r1; } public double getRadius() { return ri } public void setColor( String c) { color = c; } public String getColor() { return color; } public double getArea) { return Math.PI*r*r; } ni public String toString() { return String.format("%s Circle: r=%.2f", color, r); }; Experiment 4 X Compile Undo Cut Copy Paste Find... Close Source Code /** # Class Experiment_4 */ import java.util.*; public class Experiment_4 { public static void main(String[] args) {

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!