This is the code for this problem solve for practice.