Results 1 to 10 of 10
- 03-12-2011, 02:47 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 34
- Rep Power
- 0
-
- 03-12-2011, 03:05 AM #3
Member
- Join Date
- Jan 2011
- Posts
- 34
- Rep Power
- 0
how does selling a stock work/ what approach could i take to solve it?
i know it's not just the opposite of buying a new stock, since i have to account the subtraction and displaying the result
for example if i choose
Microsoft
MSFT
123.45
805
the result will be
Microsoft
MSFT
123.45
1 (since 806-805=1)Last edited by hiei_yasha; 03-12-2011 at 03:07 AM.
- 03-12-2011, 03:09 AM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
if all shares are sold, then the stock won't be printed if user chooses to print the information to the screen.
Is that the problem? If so, note that there will be nothing printed in that case because there is nothing to print.
Java Code:public static void printStocks(String filename, ArrayList<Stock> myList) { for (Stock s: myList) System.out.println(s.toString()); }//end printOutStocks
If you want something to print if myList is empty, test for that and print something.
Or is something else the problem? Does sellStock() do what you expect? If not, what does it do and what were you expecting?
- 03-12-2011, 03:14 AM #5
Member
- Join Date
- Jan 2011
- Posts
- 34
- Rep Power
- 0
at the moment sellStock doesn't do anything. get the same output regardless of what i enter.
that's correct that if all shares are sold, the company's information won't be printed
- 03-12-2011, 06:03 AM #6
Member
- Join Date
- Jan 2011
- Posts
- 34
- Rep Power
- 0
so i've come up with something that works, slightly off though
The only problem is if i decide to sell from a company that isn't at index 0 (so google in this case), it'll print "Company not found" since google =/= microsoft, but it will still subtract correctly and print out correctly when i prompt it to.Last edited by hiei_yasha; 03-12-2011 at 06:59 AM.
- 03-12-2011, 06:18 AM #7
Member
- Join Date
- Jan 2011
- Posts
- 20
- Rep Power
- 0
Hey man,
I though stu just wanted to change the size of the arraylist, not decrease the shares that we have...
For example, the assignment says:
6. Sell a stock – decrease the size of the ArrayList – required. You will not have an ArrayList that is too large.
All he wants us to do is decrease the size of the ArrayList. No need for all the extra work...
- 03-12-2011, 06:22 AM #8
Member
- Join Date
- Jan 2011
- Posts
- 34
- Rep Power
- 0
no, there was a series of emails floating around that said:
"According to Stu - the sell stock method must handle the cases of selling a user defined amount of stock and removing an entity if all the stock is sold. "
"
Need to handle both
Stu"
"I assume that when a stock is sold, you are asking us to delete the entire element within the list. I assumed so because the instructions say to decrease the size. Many students are thinking that they need to subtract a certain number of shares from a company."
so we need to sell the stock of an existing stock or one that we made/"bought".
for microsoft, if we decide to sell 800 shares, it'll print 6 shares.
if the number of shares = 0, ie we sell all 806 in microsoft, it must not print out when we select to print itLast edited by hiei_yasha; 03-12-2011 at 06:27 AM.
- 03-12-2011, 06:26 AM #9
Member
- Join Date
- Jan 2011
- Posts
- 20
- Rep Power
- 0
Wow seriously? I just finished an was about to submit...
- 03-12-2011, 06:29 AM #10
Member
- Join Date
- Jan 2011
- Posts
- 34
- Rep Power
- 0
Similar Threads
-
Urgent! Need help for my final year project!!
By kazuma_riku73 in forum Sun Java Wireless ToolkitReplies: 7Last Post: 06-18-2010, 11:48 AM -
Final year project idea -
By nadia in forum Advanced JavaReplies: 11Last Post: 10-28-2009, 01:22 PM -
Urgent! Need help for my final year project!!
By kazuma_riku73 in forum Sun Java Wireless ToolkitReplies: 1Last Post: 01-15-2009, 11:14 AM -
GUI Final Project help
By Unknown in forum New To JavaReplies: 21Last Post: 12-30-2008, 07:58 PM -
help to complete final part of project
By dirtycash in forum New To JavaReplies: 6Last Post: 12-31-2007, 06:21 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks