coded in JAVA, one of the class project for VT.