Hello, I'm having trouble getting the number of entries that the user makes and then using them.
Code:
public static void main(String[] args) {
// TODO code application logic here
int n, s = 0, p, i, c, m;
do {
n = Integer.parseInt(JOptionPane.showInputDialog(null, "<html>Informe um número: <br><em>(Valor 0 interrompe)</em></html>"));
s += n;
} while (n != 0);
JOptionPane.showMessageDialog(null, "<html>Resultado: <hr><br>" +
"Soma de Valores: " + s + "<br>Total de Pares:" +
"<br>Total de Ímpares:" + "<br>Acima de 100:" +
"<br>Média de Valores: </html>");
}
Explanation of variables
n -> número informado
s -> soma dos números
p -> valores pares
i -> valores ímpares
c -> números acima de 100
m -> média
Okay, the problem would be: How do I get the number of entries that the user gave?
For example, it uses the following entries: 2, 12, 31, 47, 132, 0 ;
In other words, for me to average, I should take the total and divide by the number of entries:
224 (sum) / 5 (number of entries, excluding 0)
How do I get him to count the number of tickets to use?