The answer to Assignment 1. Please read the code carefully and learn the good programming practices as much as you can.