Completed code and output