Go to Post But please, don't attempt to subvert the rules. It almost invariably becomes more trouble than it's worth. - Billfred [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #6   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


 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange Encoder Problem AIBob Electrical 3 20-02-2005 22:20
Programming Problem: Extremely Frustrating chantilly_team Programming 19 12-02-2005 23:00
Java Books Yan Wang Programming 1 27-12-2002 16:26
The problem with scouting... archiver 2001 10 23-06-2002 23:49
Major problem with chipphua motors aka Scott White Motors 18 19-03-2002 19:44


All times are GMT -5. The time now is 00:19.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi