Question: language: Java At Windows, Inc., we make stain glass windows of one particular shape. The windows are rectangular with a semi-circle on top. There is

language: Java

At Windows, Inc., we make stain glass windows of one particular shape. The windows are rectangular with a semi-circle on top. There is an image below. We put a glaze on the surface of the window. The glaze costs $2.54 a fluid ounce, and a fluid ounce will cover 10 square inches.

Complete the Window class. It has a constructor that takes the width and height (in feet) of the rectangular part of the window(in that order) as parameters. Instance variables are already defined

Implement the following methods:

public double getWidth() Gets the width of this Window (provided)

public double getHeight() Gets the height of this Window (provided)

public void setDimensions(double theWidth, double theHeight) sets a new width and height for the window

public double getArea() Gets the area of the window in square inches (updated sept 20)

public double getCostOfGlaze() Gets the cost of the glaze needed for this window. So not calculate the area again in this method. Call another method in the class.

Note: the width of the rectangle is also the diameter of the semi-circle. Note: you will have to do some units conversion.

Use Math.PI

Do not use magic numbers in your code. Use constants provided for number of square inches in a square foot, for the number of square inches an ounce will cover, and for cost of the glaze per ounce. The constant for in/ft is below. You provide the one for cost of the glaze per ounce

public static final double COST_PER_OUNCE = 2.54; public static final int SQUARE_INCHES_PER_SQUARE_FOOT = 144; public final static int SQUARE_INCHES_PER_OUNCE_OF_GLAZE = 10;language: Java At Windows, Inc., we make stain glass windows of one

Use the following file:

WindowTester.java

public class WindowTester { public static void main(String[] args) { double width = 1.4; double height = 4.2; Window window1 = new Window(width, height); width = 3; height = 10; Window window2 = new Window(width, height); System.out.printf("%.2f ",window1.getArea()); System.out.println("Expected: 957.56"); System.out.printf("%.2f ",window1.getCostOfGlaze()); System.out.println("Expected: 243.22"); System.out.printf("%.2f ",window2.getArea()); System.out.println("Expected: 4828.94"); System.out.printf("%.2f ",window2.getCostOfGlaze()); System.out.println("Expected: 1226.55"); window1.setDimensions(3, 10); System.out.printf("%.2f ",window1.getCostOfGlaze()); System.out.println("Expected: 1226.55"); } } 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/** * models a rectangular window with a semi-circle on top */ public class Window { public static final double COST_PER_OUNCE = 2.54; //constant public static final int SQUARE_INCHES_PER_SQUARE_FOOT = 144; //constant public final static int SQUARE_INCHES_PER_OUNCE_OF_GLAZE = 10; //constant private double width; private double height; //put your constructor here /** * Gets the width of this Window * @return the width of the Window */ public double getWidth() { return width; } /** * Gets the height of this Window * @return the height of the Window */ public double getHeight() { return height; } //put your methods here }

Description glass is typically found on church windows for decorative purposes. Clipart courtesy FCIT St. Michael (archangel) casting out the great red dragon. stained http://etc.usf.edu/clipart/

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!