Quote:
How to print the sum along with the series
Your code is nowhere near what you want it to do. So o,ly the print part.
By using
System.out.println
you ensure that you will print only 1 thing per line. You should try
System.out.print
to avoid a new line after each part to print.