View Single Post
  #9   Spotlight this post!  
Unread 30-03-2005, 11:09
dm0ney's Avatar
dm0ney dm0ney is offline
Will Code For Food (Food Optional)
AKA: Deepak Mishra
None #0217 (The ThunderChickens)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Shelby Twp., MI
Posts: 48
dm0ney will become famous soon enough
Send a message via AIM to dm0ney
Re: Java headache problem

Code:
public class SellStockTest
{
public static void main(String[] args)
{
//Declares, Instantiates new SellStock class
    SellStock iSellStock = new SellStock();
//Price of stock
    iSellStock.addPrice(10.125);
//Number of stock
    iSellStock.addNumbers(11);
//Calculate Value of Stock!
    iSellStock.addValue();
//Add commission owed from stock sales, Calculates
    iSellStock.addCommission(1.5);

//Not sure what you wanted here?
    double totalValue = iSellStock.getProceeds();
//Print out statements
System.out.print("This program calculates the net proceeds from a sale of stock to be:");
//This could either be as follows or you could printout totalValue since you declared it above.
System.out.println(iSellStock.getProceeds());
}
EDIT: must declare variables like AIBOB above said. I did that and forgot to forward that on to you.

This is an edited version of the last class. You never calculated the value of the stock, so it would output zero. I added your function call to calculate Value (addValue()) and to my knowledge it works in that implementation.

Might I suggest using setValue, setXXXX, getXXXX for variables. The addXXXX gets confusing. Also change the counts to something even iXXXX where X is the variable and set price = iPrice.

Hope that helps, Good Luck.
__________________

Alumni
Team #217, The ThunderChickens



Student, Class of 2009
California Institute of Technology