C++ Programming Exercise from the book C++ Programming: From Problem Analysis To Program Design by D.S. Malik 5th Edition