class stacktriangle app static int thenumberstatic int theanswerstatic stackx thestackpublic static void main(string[argsthrows ioexception system out print("enter number")system out flush()thenumber getint()stacktriangle()system out println("triangle="+theanswer)/end main(//public static void stacktriangle(thestack new stackx( )/make stack theanswer /initialize answer while(thenumber thestack push(thenumber)--thenumberwhile!thestack isempty(int newn thestack pop()theanswer +newn/until is /push value /decrement value /until stack empty/pop value/add to answer //public static string getstring(throws ioexception inputstreamreader isr new inputstreamreader(system in)bufferedreader br new bufferedreader(isr)string br readline()return //public static int getint(throws ioexception string getstring()return integer parseint( )