Imagine that I am building a smart contract which simulates a lottery. I would like people to enter the lottery by buying a ticket (i.e. they would send in a certain amount of ether when they call a specific function on my contract).
Can I implement the purchase functionality so that a ticket always costs the equivalent of $2 USD? This doesn't seem straightforward given that the value of ether is constantly changing.
Wanting to have something cost a set price seems like it would occur frequently so I'm wondering if there is a standard way to implement it.
Note: I am just starting out with Ethereum/Solidity so I apologize if this is a very basic question.