0
Make a program that calculates the arithmetic mean of N banknotes using array.
I’m trying to do this:
package exer4;
import java.util.Scanner;
public class Exer4 {
public static void main(String[] args){
int nota[] = {4,5,7,4,3,6,6,8,3,4};
int perguntar = in.nextInt();
int aluno = 0;
int soma = 0;
while(aluno < 10){
System.out.println("Aluno: " + aluno + " Nota: " + nota[aluno]);
aluno++;
}
for(int i = 0; i < nota.length; i++){
soma = soma + nota[i];
System.out.println(soma);
}
}
}
I did it that way:
package exer4;
import java.util.Scanner;
public class Exer4 {
public static void main(String[] args){
Scanner in = new Scanner (System.in);
int nota[] = {1,4,5,7,6, inserir};
int inserir = in.nextInt();
System.out.println("Digite as suas notas e espere a media");
System.out.println("Sua nota pode ser:" + nota);
System.out.println("Sua media pode ser:" + nota / 2);
}
}
I’m trying this other way too:
package exer4;
import java.util.Scanner;
public class Exer4 {
public static void main(String[] args){
Scanner in = new Scanner (System.in);
int nota[] = {1,4,5,7,6, inserir};
nota[0] = in.nextInt();
System.out.println("Digite as suas notas e espere a media");
System.out.println("Sua nota pode ser:" + nota);
System.out.println("Sua media pode ser:" + nota / 2);
}
}
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site (when you have enough score).
– Maniero