write lab5 and lab6 code