Java Reference
In-Depth Information
11 Stockbroker's Commission
Draw a flowchart and then develop an application that allows a user to enter a
stock purchase transaction and determine the stockbroker's commission. Each
transaction includes the following data: the stock name, price per share, number
of shares involved, and the stockbroker's name. Assuming price per share = P, the
stockbroker's commission is computed in the following manner:
If P (price per share) is less than or equal to $75.00, the commission rate is
$0.19 per share; if P is greater than $75.00, the commission rate is $0.26 per
share. If the number of shares purchased is less than 150, the commission is 1.5
times the rate per share.
Write code so that the program displays a message box that includes the
stock transaction data and the commission paid the stockbroker in a grammati-
cally correct set of sentences. After the message box displays, reset the input val-
ues to their original state.
12 Volume Computations
Use good design and programming techniques to develop a program to compute
the volume of a box, cylinder, cone, and sphere. The user interface should pro-
vide option buttons to allow the users to select a shape. The interface also should
include four input fields that allow a user to enter numbers with two decimal
places; each input field should indicate that the input value is measured in feet.
Label the four input fields as Length, Width, Height, and Radius.
When the user clicks a button to perform the calculation, the button's event
procedure first should determine that the user selected a shape type. Next, the
event procedure should ensure that only nonzero, positive values have been
entered for the measurements required for the particular formula being used.
Finally, the program should perform the calculation and display a message box
listing the inputs, output, and calculated volume in a suitable format:
For example, the volume of a box with a length of 1.00 feet, a width of 2.00
feet, and a height of 3.00 feet is 6.00 cubic feet.
Use the following formulas to determine the volumes of the various shapes:
1. Volume of a box: V = L x W x H, where L is the length, W is the width, and
H is the height of the box
2. Volume of a cylinder: V = pi x R x R x H, where R is the radius and H is the
height of the cylinder
3. Volume of a cone: V = (pi x R x R x H)/3, where R is the radius of the base,
and H is the height of the cone
4. Volume of a sphere: V = (4/3) x pi x R x R x R, where R is the radius of the
sphere
In all of the above formulas, use either 3.14 or the Java constant, Math.PI,
for the value of pi. You may use the Math.Pow() method for exponentiation.
Search WWH ::
Custom Search