Statistics

Problem Statement for "GlassCo"

Problem Statement

PROBLEM STATEMENT

Class: GlassCo
Method: glassArea
Arguments: int, int, int, int, int
Returns: int

Classical Glass Company, Inc., needs to know how much actual glass is required
for a multi-paned window frame. Given the width and height of the entire frame,
the width of each inside frame, the number of panes across, and the number of
panes down, you need to determine the area of glass in square inches. All units
are in inches. Assume that there is a border around the outside of the entire
window frame equal in width to the inside frame widths.

Here is the method signature (make sure your method is public): int
glassArea(int width, int height, int insidewidth, int numacross, int numdown)

All arguments will be between 1 and 100, inclusive. TopCoder will enforce this
restriction.

For instance, parameters of (65, 49, 1, 4, 6) require a 65x49 total frame size.
You have 4 panes across, with a one inch frame between each one, and two more
inches of frame (one for each edge). So, each pane is ((65 - 5) / 4) inches
horizontally. With 6 panes down, each pane is ((49 - 7) / 6) inches vertically.
Therefore, each pane is 15 inches by 7 inches. There are 4*6 panes, so (4*6) *
(15*7) returns 2520 (square inches).

Parameters of (34, 14, 2, 4, 2) are illustrated as follows: (The '*' are the
frame, blank spaces (' ') are the glass itself.

    1234567890123456789012345678901234
 1  **********************************
 2  **********************************
 3  **      **      **      **      **
 4  **      **      **      **      **
 5  **      **      **      **      **
 6  **      **      **      **      **
 7  **********************************
 8  **********************************
 9  **      **      **      **      **
 10 **      **      **      **      **
 11 **      **      **      **      **
 12 **      **      **      **      **
 13 **********************************
 14 **********************************

We have 4*2 = 8 panes, each 6*4 = 24 square inches, so 8 * 24 = 192 total area.

NOTE: Individual panes do not have to have integer dimensions.

If the resulting window panes would have a negative size in either dimension
(mathematically), return 0.
For instance, (10, 10, 5, 2, 2) would be (10 - (3*5)) / 2 = -2.5 inches wide.

Examples:
(15, 37, 3, 2, 1) returns 186
(42, 11, 5, 3, 2) returns 0
(42, 65, 5, 3, 2) returns 1100

Definition

Class:
GlassCo
Method:
glassArea
Parameters:
int, int, int, int, int
Returns:
int
Method signature:
int glassArea(int param0, int param1, int param2, int param3, int param4)
(be sure your method is public)

Constraints

    Examples


      This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
      This problem was used for: