Online Learning Algorithms For Stochastic Inventory And Queueing Systems