I can connect the key pad with arduino and i can connect the lcd with arduino separately but i cant seem to merge the link between the keypad and lcd together ,as my program required me to set some settings by pressing buttons on the keypad and making the value appear on the lcd .
I think you are getting slowly to the point. You are not asking how to simply connect lcd and keypad to your mega, but how to get your mega a user inteface to input numbers. Is that right? Try to be more specific how exactly you want to iniput what. Someone may have some code for you.
There might even be some tutorial for that. I have not made any myself but you are welcome to try out my sample codes.
look for phi_interfaces library on arduino playgrounds. I'm on ipad now, no way to easily get you a link.