Results 1 to 3 of 3
  1. #1
    askinne2 is offline Member
    Join Date
    Apr 2010
    Posts
    15
    Rep Power
    0

    Default 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.

    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
    	}*/
    	
    	
    }
    errors:
    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
    Thanks guys!
    Last edited by askinne2; 05-01-2010 at 11:55 PM.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,658
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by askinne2 View Post
    errors:
    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
    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

  3. #3
    askinne2 is offline Member
    Join Date
    Apr 2010
    Posts
    15
    Rep Power
    0

    Default

    Thanks for your reply. I have solved all my issues now though so I am good to go!

Similar Threads

  1. knowledge exchange
    By jeeprogrammer in forum New To Java
    Replies: 0
    Last Post: 09-26-2009, 03:30 AM
  2. exchange the position of array elements
    By hacikho in forum New To Java
    Replies: 6
    Last Post: 09-20-2009, 10:02 PM
  3. Stock Quotes
    By BartDR in forum Advanced Java
    Replies: 0
    Last Post: 09-15-2009, 09:15 AM
  4. Replies: 2
    Last Post: 04-17-2008, 05:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •