0
I made this algorithm that performs the sum of arguments inserted, but it shows something else.
package ExerciciosSintaxe;
import java.util.Scanner;
public class Ex7 {
public static void main(String[] args) {
int soma = 0;
for(int i=0; i<args.length; i++) {
System.out.printf("\nEntre com numeros #%d: %s ", i, args[i]);
try {
int n= Integer.parseInt(args[i]);
soma +=n;
System.out.println(soma);
} catch(NumberFormatException e1) {
}
try {
double d = Double.parseDouble(args[i]);
soma +=d;
System.out.println(soma);
} catch(NumberFormatException e2) {
System.out.printf("\nNumero #%d invalido", i);
}
}
}
}
If I type for example 2 integers: 12 14, it shows this:
Entre com numeros #0: 12 12
24
Entre com numeros #1: 14 38
52
To mark the answer as accepted do so: http://i.stack.Imgur.com/uqJeW.png
– Piovezan