Homework program6 by Ivailo Ivanov