I have made a program in java, which decomposes in a sum of numbers some, to a value x, which is entered by the user. The inconvenience that I have is when I deploy, since I always have an extra "+" sign, example: stable that the limit is 5.
1
1 + 1 +
1 + 1 + 1 +
1 + 1 + 1 + 1 +
1 + 1 + 1 + 1 + 1 +
and I get this answer. How could I do, to remove that extra sign so annoying? (I have tried in several ways, but I have not managed to reach the desired result)
code:
String coma ="+";
String serie="";
int unos=1;
int li=0;
int cont=0;
String u="1";
Scanner sc = new Scanner(System.in);
System.out.println("Ingrese limite para la generación de laa sucesión");
li= sc.nextInt();
int other;
int other2;
other=li;
other2=li;
other2=other2-1;
int te=1;
for(int i=1; i<=li; i++)
{
for(int j=0; j<(other-other2); j++)
{
if(i>1)
{
serie= u+coma;
System.out.print(serie);
}
else
{
System.out.print(u);
}
}
System.out.println("");
other2--;
}