In Stock Ticker, you roll the dice to see what happens to the stocks. There are three possible outcomes for a?
Posted by admin
rohit asked:
In Stock Ticker, you roll the dice to see what happens to the stocks. There are three possible outcomes for a stock: stock goes up, stock goes down, and stock pays dividend. We will ignore the case of dividends for this question. When a stock changes value, it can change by an amount of 0.05, 0.10, or 0.20.
(A) Write a pseudocode function that rolls the dice and figures out by how much a stock will change, returning the amount of change.
(B) Write pseudocode that initializes the stock values as an array, and then calculates the new values of the stocks after rolling all the dice 5 times. Call the function in (A) to figure out the amount of change, and roll one extra die to determine which stock to apply the result to.
Question posted courtesy of: Earl
In Stock Ticker, you roll the dice to see what happens to the stocks. There are three possible outcomes for a stock: stock goes up, stock goes down, and stock pays dividend. We will ignore the case of dividends for this question. When a stock changes value, it can change by an amount of 0.05, 0.10, or 0.20.
(A) Write a pseudocode function that rolls the dice and figures out by how much a stock will change, returning the amount of change.
(B) Write pseudocode that initializes the stock values as an array, and then calculates the new values of the stocks after rolling all the dice 5 times. Call the function in (A) to figure out the amount of change, and roll one extra die to determine which stock to apply the result to.
Question posted courtesy of: Earl










