예제 #1
0
        public static Double calculateDividendYield(String stockSymbol)
        {
            Double returnValue = 0;
            Stock  stock       = Stock.findStockbySymbol(stockSymbol);

            try
            {
                if (stock.type.Equals("Preferd"))
                {
                    returnValue = stock.lastDividend / tickerPrice;
                }
                else if (stock.type.Equals("Common"))
                {
                    returnValue = stock.fixedDividend * stock.parValue / tickerPrice;
                }
                else
                {
                    Console.WriteLine("WARNING: Wrong Stock type!!");
                }
            }
            catch (DivideByZeroException ex)
            {
                Console.WriteLine("ERROR: DivideByZeroException: Have a look on the stock.parValue of the Stock= " + stock.symbol);
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: Ooops! Something went wrong");
                Console.WriteLine("ERROR MESSAGE: " + ex.Message);
            }
            return(returnValue);
        }
예제 #2
0
        public static Double PERatio(String stockSymbol)
        {
            Double returnValue = 0;
            Stock  stock       = Stock.findStockbySymbol(stockSymbol);

            try {
                returnValue = tickerPrice / stock.lastDividend;
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: Ooops! Something went wrong");
                Console.WriteLine("ERROR MESSAGE: " + ex.Message);
            }
            return(returnValue);
        }