0
enunciation: It is intended to develop a program that will carry out the following: 1. asks to read a given paragraph N of integers or non-integers and positives or not from the keyboard; 2. These N numbers shall be entered, and then the program shall display on the screen a list of the following classifications: - number of whole numbers read - number of fractional numbers read - number of negative numbers read - number of positive numbers read - sum of negative numbers read - sum of positive numbers read - mean of negative numbers read - mean of positive numbers read - sum of all read numbers - average of all numbers read
what I managed to do:var n, sum, media, listing;
n = Number(prompt("Qual o a quantidade de números que quer introduzir?"));
listagem = "Calculo da média dos números";
listagem += calMedia(n);
alert(listagem);
function calMedia(num) {
soma = 0;
for(var i = 1; i <= num; i++) {
soma += Number(prompt(i + "º número?"));
}
media = soma / num;
listagem += "\nNºs lidos: " + num;
listagem += "\nSoma dos nºs lidos: " + soma;
listagem += "\nMédia dos nºs lidos: " + media;
return listagem;
}
but it needs to have a cycle and I know where to put it
– Carlos Monteiro