Home Segments Index Top Previous Next

461: Practice

If a company is losing money, then the notion of a price–earnings ratio makes no sense.

Modify the program shown in Segment 458 such that the appearance of 2 as the leading integer in a line of data indicates that there is to be no price earnings ratio, and that the data are to be used to construct an object of type stock_trade_without_ratio. Define stock_trade_without_ratio and include it in the definition of the trade union. Try your revised program on the following data.

0   3.3  300 10 
2   2.5  400  
1   9.9  100 4.5 
1  10.1  100 6.2 
0   5.0  200 12 
2   9.1  100