0
Hello, I’m having difficulty picking up the number of entries that is made by the user to then use 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
Right, the problem would be: How do I get the number of entries the user gave?
For example, it uses the following entries: 2, 12, 31, 47, 132, 0;
I mean, for me to make the average I should take the total and divide by the number of entries:
224 (summing up) / 5 (number of entries, excluding 0)
How do I get him to count the number of tickets to use?
They are two very different questions together, I recommend separating them, even because the second one is a little confused. Perhaps separating it into a new one you can explain better without making the question broad.
– user28595
Okay, I corrected the question and left the main theme
– maxxzag