BO(Question 4.6.1:) Study, compile and run the following code. Note the use
of the class variable TT(myMoney). A class variable is different from a
variable that is local to a FUNCTION because the lifetime of the class
variable is for the duration that the program is run, whereas the
lifetime of a local variable is for the duration of the FUNCTION
call. In the code that follows, the variable TT(myMoney) is used to
store a numerical value, for how much money you have.

@cindex Introducing class variables

@example
CLASS Money
BEGIN
PD COMM(/** Property myMoney stores money value in dollars */)
PD CLASSVAR int myMoney;

PD FUNCTION void spend(String item, int value)
PD BEGIN
PD PD myMoney = myMoney - value;
PD PD System.out.println("*** spent $" +
PD PD PD PD PD PD PD PD  value +
PD PD PD PD PD PD PD PD  " on " + item +
PD PD PD PD PD PD PD PD  ", leaving you with $" + myMoney);
PD PD END
PD END
PD BEGINMAIN
PD PD myMoney = 100;
PD PD spend("aquarium",50);
PD PD spend("shoes",100);
PD PD spend("lipstick",20);
PD ENDMAIN
END
@end example

BO(Question 4.6.2:) Change the myMoney class variable so that it is a double
(short for double-precision floating point) rather than an int. You
will need to add a new FUNCTION money2string that converts double
values into strings. For example the floating point number 1.2345
should be printed out as $1.23. If x is a double then the following
expression converts x from a double into a number of dollars (int)x
and the following expression converts x into a number of cents
(int)(money * 100) - 100 * dollars. Note that you will need to make it
so that $1.03 prints out as this value.

BO(Question 4.6.3:) Add an if statement to the spend FUNCTION so that it
uses TT(System.out.println()) to print out an error message if the
person does not have enough funds in their bank account to pay for the
item parameter.

BO(Question 4.6.4:) Add a new CLASS variable DOUBLE
TT(governmentsMoney) and make it so that 12.5% of the cost of each
item goes to the government in the form of G.S.T., which stands for
Goods and Services Tax, a value-added tax.

BO(Question 4.6.5:) Add a new class variable TT(numBattleships) that records
how many batteships are owned by the government. Write a FUNCTION
TT(buyBattleShips) that causes the government to buy as many battleships
as it can afford. Make it so that the TT(buyBattleShips) FUNCTION prints
out how many battleships were purchased. Let the cost of each
battleship be one million dollars and store this value in a variable
called TT(costOfShip). Please note that if the government's money is less
the one million dollars then no battleships will be purchased.

BO(Question 4.6.6:) Set the initial value for TT(governmentsMoney) to be two
millions dollars, then call the TT(buyBattleShips) FUNCTION and verify
that two battleships were purchased.
