Show your current code.its not working

Yes, but you should try and come up with it yourself. As I suggested, if you are having trouble solving your entire problem at one go, break it down into parts and solve each part separately, then combine the knowledge you gain from solving them separately to help you solve the entire problem.any way you got any idea on how to do this in other way? where if i keyin -1 it will terminate the program..