I will write example code according to your requirements
