Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Laboratório de Programação 2 - Lab 1
- *
- * @author Amanda V. A. de Luna e Costa - 116210896
- */
- import java.util.Scanner;
- import java.util.ArrayList;
- public class ResultadosProva {
- public static void main(String[] args) {
- Scanner entrada = new Scanner(System.in);
- ArrayList<Integer> notas = new ArrayList<Integer>();
- while(true){
- String linha[] = entrada.nextLine().split(" ");
- if(linha[0].equals("-")){
- break;
- }
- else{
- notas.add(Integer.parseInt(linha[1]));
- }
- }
- int menor = notas.get(0);
- int maior = notas.get(0);
- int soma = 0;
- for(int i=0; i<notas.size() ; i++){
- if(notas.get(i)< menor){
- menor = notas.get(i);
- }
- if(notas.get(i) > maior){
- maior = notas.get(i);
- }
- soma += notas.get(i);
- }
- float media = soma/notas.size();
- int acima = 0;
- int abaixo = 0;
- for (int i=0; i<notas.size() ; i++){
- if(notas.get(i) >= 700){
- acima += 1;
- }
- else {
- abaixo += 1;
- }
- }
- System.out.printf("maior: %d\n",maior);
- System.out.printf("menor: %d\n",menor);
- System.out.printf("media: %.0f\n",media);
- System.out.printf("acima: %d\n",acima);
- System.out.printf("abaixo: %d\n",abaixo);
- entrada.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement