java package - money



good evening guys,
i am finding a piece of work extremely tough going at the moment and
wondered if i could get any hints/help on where im going wrong. i am
aiming to produce a package (money.java) which could be used in order
to produce arithmetic calculations on sums of money.

The code i have at the moment is:

MONEY.JAVA:

package java;


public class money
{
private int data1, data2;

public money()
{
data1=0;
data2=0;
}

public money(int value1, int value 2)
{
data1 = value1;
data2 = value2;
}

public void addMoney(int value1, int value2)
{
return value1 + value2;
}

public void subtractMoney(int value1, int value2)
{
return value1 - value2;
}

public void divideMoney(int value1, int value2)
{
return value1 / value2;
}

public void multiplyMoney(int value1, int value2)
{
return value1 * value2;
}

}

MONEYTEST.JAVA


import java.money;

public class MoneyTest
{
public static void main(String [] args)
{
money p = new money(10,20);
System.out.println("The total is " + p.addMoney());
}
}

I think i may need a 'toString' method? and also, is there any way of
covering errors? im sorry if these problems are trivial. I have various
books, but can't seem to use them in this case.

Thank you for any feedback.

Jess

.



Relevant Pages

  • java package - money
    ... to produce arithmetic calculations on sums of money. ... public void addMoney(int value1, int value2) ... public void subtractMoney(int value1, int value2) ...
    (comp.lang.java.help)
  • java package - money
    ... to produce arithmetic calculations on sums of money. ... public void addMoney(int value1, int value2) ... public void subtractMoney(int value1, int value2) ...
    (comp.lang.java.help)
  • java package - money
    ... to produce arithmetic calculations on sums of money. ... public void addMoney(int value1, int value2) ... public void subtractMoney(int value1, int value2) ...
    (comp.lang.java.help)
  • java package - money
    ... to produce arithmetic calculations on sums of money. ... public void addMoney(int value1, int value2) ... public void subtractMoney(int value1, int value2) ...
    (comp.lang.java.help)
  • Re: java package - money
    ... public money(int value1, int value 2) ... public void addMoney(int value1, int value2) ... You don't really need to repeat the word "Money" in the method names, since the methods are specific to the "Money" clss anyway. ...
    (comp.lang.java.help)