how to read characters from user and construct a sting and then extract part of it using substring?