#C13715. Real-time Stock Ticker Simulation
Real-time Stock Ticker Simulation
Real-time Stock Ticker Simulation
This problem requires you to simulate a real-time stock ticker. You are given a stock symbol and a duration (in seconds). For each second, you are to print the current stock price in a specific format. To ensure deterministic behavior (and allow for easy testing), the stock price for the i-th second is computed using the formula:
\(price = 100 + ((i \times 37) \bmod 401)\)
The result should be printed with exactly two decimals. For example, if the stock symbol is TEST
and the duration is 3
, your program should output:
The current price of TEST is $137.00 The current price of TEST is $174.00 The current price of TEST is $211.00
Note: Although the description mentions a real-time simulation, for the purpose of this problem the outputs should be produced immediately without any deliberate delays.
inputFormat
The input is read from stdin and consists of two lines:
- The first line contains a non-empty string
symbol
representing the stock symbol. - The second line contains an integer
duration
which indicates the number of price updates to print.
outputFormat
For each second from 1 to duration
, print a line to stdout in the following format:
The current price of {symbol} is ${price}
Here, {symbol}
is the input stock symbol, and {price}
is determined by the formula:
\(price = 100 + ((i \times 37) \bmod 401)\)
The price must be formatted with exactly two decimal places.
## sampleTEST
3
The current price of TEST is $137.00
The current price of TEST is $174.00
The current price of TEST is $211.00
</p>