This assignment concerns a method of using randomized estimation to determine an area of a non-rectangular
object. For this assignment you will make a program to calculate the amount of plywood required to
construct a ramp for use in skateboarding, as discussed in class. The shape of the ramp will be given by
an equation. For example, a half-pipe
shape would be given by a polynomial equation.
The assignment is to make SkateRamp.java, which computes the area of the supports for the skateboard half-pipe
as shown in this picture. Your program must be able to handle a
description of the shape of the halfpipe using polynomials of arbitary degree, as well as trigonometric and
other functions [log, exponential, etc.]. If the program is invoked incorrectly, it should, as usual,
output a clear message to tell the user the proper way to run the program. Your program will be invoked as
follows:
java SkateRamp args[0] args[1] args[2] … args[k-1] args[k] lowerBound upperBound percent%
where args[0] is the name of a function type; args[1] … args[k] specify
the coefficients of the x0 … xk terms of the polynomial; lowerBound
and upperBound specify the lower and upper bounds of x, i.e., the range of the X-values that
will be used for evaluating; and finally percent% indicates when the program should halt
– specifically, the program should halt when two successive approximations are within
percent percent of one another.
[NOTE: the "%" at the end is
required; the value will be expressed as a number with the "%" at the end,
i.e., "0.0023%".]
The following additional conditions apply:
SkateRamp.Java, which can integrate various functions that are
built into your program. Here are some examples of how it might be invoked:
java SkateRamp poly 1.0 -2.1 3.2 -10.0 +5.0java SkateRamp poly 1.0 -2.1 3.2 -10.0 +5.0 1.0%java SkateRamp poly 0.0 8.0 -2.0 1.0 4.0 1e-6%java SkateRamp sin -0.27 +3.55java SkateRamp log 1.1 2.3java SkateRamp exp 2.0 3.5java SkateRamp sqrt 1.0 2.0java SkateRamp functionName additionalDescriptorssin and sqrt] do not necessarily require them.modulesfor better
separation of concerns.
private static void runMyTests()
which will make method calls to a set of test methods. Since you need a main() method to run
your program already, you must put the tests in another method. Name that method runMyTestsand make your main program check for that on the command line in
args[0]. In other words, you MUST be
able to run your program using:java SkateRamp runMyTestsrunning poly test with 1.0 -2.3 -1.0 3.0 with 0.0001% ~
expected: 123.45, got: 123.45.polynomials of at least degree 2 [you MUST start with this]polynomials of arbitrary degree [which you may as well do when you have the
first part working]sin function [you MUST implement this as well]cos, tanlog and exponentiation functionssqrt (1 + cos(x) ) or cos(x)cos(2x).
Make sure that your lab report clearly explains how these should be invoked.Notes:
sin function to work.Submission Guidelines: Make a sub-directory in your repository as mentioned above,
called homework05
and commit your source code into it. DON'T FORGET TO ADD A COMMIT COMMENT!