Home Segments Index Top Previous Next

173: Practice

Write a program that transforms a company's price–earnings ratio into one of three messages: “The company appears to be undervalued,” “The company appears to be normally valued,” or “The company appears to be overvalued.” Your program's input is four numbers: the first is the price of the stock, the second is the number of shares outstanding, the third is the most recent annual earnings of the company, and the fourth is the average price–earnings ratio for companies in the same line of business. The overvalued and undervalued messages should not appear unless the company's price–earnings ratio differs from the average by more than 10 percent.