CS46A Spring 19

4A

At Java Inc, we want to sell a large helium balloon printed with the words "Java Rules." It is up to you to figure out what price to charge so that we make $2 profit per balloon. The balloon itself cost $5.50. We buy a tank of helium for $235.00. The tank holds 300 cubic feet.

Write a class HeliumBalloon

public HeliumBalloon( double theRadius) where radius is given in inches

Use these constants:
public static final int CUBIC_INCHES_PER_CUBIC_FOOT = 1728;
public static final double PROFIT = 2.0;

Also define and use constants for PRICE_OF_BALLOON, PRICE_OF_TANK, and VOLUME_OF_TANK_IN_CUBIC_FEET.

Provide Javadoc

For the draft, define the instance variable, the constructor, getRadius, setRadius, and the constants. You should only have one instance variable. Provide Javadoc

Formula for volume of a sphere (in case you need it)

formula for volume of sphere

4A draft:
4A final:

4B

Write an application Vegetable. (An application has a main method.)

Create a Scanner object and do the following..

Only create one Scanner.

For the draft, create the Scanner and do the first three steps.

4B draft:
4B final:

4C

Write a class StringsRUs that creates a Scanner and does the following:

Hint: To get just the first name, you need to know the index of the first space. You can find the index of the first space with the indexOf method. str.indexOf(" ") will return the index of the first space or -1 if there are no spaces in str. You can assume there is at least one space so you do not need to worry about -1 for this problem. After you find the index of the fist space, you can use substring to get the first name.

For the draft, do the first two steps.


4C draft:
4C final: