Results 1 to 3 of 3
Thread: Stock exchange program
- 05-01-2010, 08:59 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 15
- Rep Power
- 0
Stock exchange program
Hey guys. I got great help last time I need help and I would greatly appreciate steps in the right direction and any help/advice you can offer now. I am making a stock exchange program (requirements here: link) and this is what I have got up to now.
I am trying to parse this text file and store the values into portfolio objects(these things hold all the information of one particular fund). I want to store all these objects into an array as well. I am getting a few errors in the class that is parsing the text file.
errors:Java Code:import java.util.Scanner; import java.io.*; public class Portfolio { String name; String symbol; double buyingPrice; double currentPrice; double floorSellingPrice; double ceilingSellingPrice; double profit; int shares; enum Type{bond, stock, cash}; Type type; String info; public Portfolio(String EXname, String EXsymbol, Type EXtype, double EXbuyingPrice, int EXshares, double EXfloorSellingPrice, double EXceilingSellingPrice, String EXinfo) { name = EXname; symbol = EXsymbol; type = EXtype; buyingPrice = EXbuyingPrice; shares = EXshares; floorSellingPrice = EXfloorSellingPrice; ceilingSellingPrice = EXceilingSellingPrice; info = EXinfo; } public Portfolio inputPortfolio(String input) { int indexPosition = 0; int arrLength = 0; try { String fileName = "c://portfolio.txt"; //sets s to value of location of the text file FileInputStream fi = new FileInputStream(fileName); //creating new file input source object Scanner scan = new Scanner(fi); //creating file reader object Portfolio[] arrFundHolder; try //finding how many objects are in the text file { while(scan.hasNextLine()) { arrLength++; } arrFundHolder = new Portfolio[arrLength]; } catch(Exception e) //catching exception { System.out.println(e); } arrFundHolder = new Portfolio[arrLength]; while(scan.hasNextLine()) { String TEMPname = scan.next(); String TEMPsymbol = scan.next(); Type TEMPtype = scan.next(); double TEMPbuyingPrice = scan.nextDouble(); int TEMPshares = scan.nextInt(); double TEMPfloorSellingPrice = scan.nextDouble(); double TEMPceilingSellingPrice = scan.nextDouble(); String TEMPinfo = scan.next(); return new Portfolio(TEMPname,TEMPsymbol,TEMPtype,TEMPbuyingPrice,TEMPshares,TEMPfloorSellingPrice,TEMPceilingSellingPrice,TEMPinfo); arrFundHolder[indexPostion] = Portfolio(); indexPosition++; scan.close(); fi.close(); } } catch(Exception e) { System.out.println(e); } } /*public double getCurrentPrices() { prompt for current prices }*/ /*public double computerProfit() { compute profit for stock and bond funds }*/ /*public String displayAnalysis() { display a sell or hold reccomendation }*/ }
Thanks guys!Java Code:Portfolio.java:61: cannot find symbol symbol : method nextString() location: class java.util.Scanner Type TEMPtype = scan.nextString(); ^ Portfolio.java:68: cannot find symbol symbol : variable indexPostion location: class Portfolio arrFundHolder[indexPostion] = Portfolio(); ^ Portfolio.java:68: cannot find symbol symbol : method Portfolio() location: class Portfolio arrFundHolder[indexPostion] = Portfolio(); ^ 3 errors
Last edited by askinne2; 05-01-2010 at 11:55 PM.
- 05-02-2010, 07:49 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
The code you posted is not the code that caused the error diagnostic messages, e.g. there is no nextString() method to be seen in your code. We can't help you further than to repeat the compiler on the other error message: the variable 'indexPostion' is never declared in your code.
kind regards,
Jos
- 05-02-2010, 11:25 PM #3
Member
- Join Date
- Apr 2010
- Posts
- 15
- Rep Power
- 0
Similar Threads
-
knowledge exchange
By jeeprogrammer in forum New To JavaReplies: 0Last Post: 09-26-2009, 03:30 AM -
exchange the position of array elements
By hacikho in forum New To JavaReplies: 6Last Post: 09-20-2009, 10:02 PM -
Stock Quotes
By BartDR in forum Advanced JavaReplies: 0Last Post: 09-15-2009, 09:15 AM -
Java program that transfers stock prices to MySQL database
By naipulb in forum New To JavaReplies: 2Last Post: 04-17-2008, 05:02 PM


LinkBack URL
About LinkBacks


Bookmarks