triangle()system out println("triangle="+theanswer)/end main(//public static void rectriangle(thestack new stackx( )codepart whilestep(=false/call step(until it' true /null statement //public static boolean step(switch(codepartcase /initial call theseparams new params(thenumber )thestack push(theseparams)codepart breakcase /method entry theseparams thestack peek()if(theseparams = /test theanswer codepart /exit else codepart /recursive call breakcase /method call params newparams new params(theseparams )thestack push(newparams)codepart /go enter method breakcase /calculation theseparams thestack peek()theanswer theanswer theseparams ncodepart breakcase /method exit theseparams thestack peek()codepart theseparams returnaddress/( or thestack pop()breakcase /return point return true/end switch