Third version

The program is divided into three parts.
Added check the validity of data.