0
I have the following exercise that asks me to define an interval and sum all the even values of that interval showing which numbers are summed between them, like:
Min=10
Max=1510+12+14=36.
However. the output I get is:
10+12+14+=36.
That is.I have an extra "+". I leave the code here:
int min = 0;
int max = 0;
do{
do{
System.out.println("Insira um valor min:");
min = scanner.nextInt();
System.out.println("Insira um valor max:");
max = scanner.nextInt();
}while (min<0 || max >100);
}while(min>max);
int i = 0;
while((min<max))
{
if(min % 2==0)
{
i+=min;
System . out . print(min + "+");
}min++;
}
System . out . print("=" + i);
I prefer
String sinal = "";...soma+=valor;sysout(sinal+valor);sinal="+"
=)– mari
@Mari It may also be.
– Victor Stafusa