Advertisement
Avdluna

Untitled

May 14th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. /**
  2.  * Laboratório de Programação 2 - Lab 1
  3.  *
  4.  * @author Amanda V. A. de Luna e Costa - 116210896
  5.  */
  6.  
  7. import java.util.Scanner;
  8. import java.util.ArrayList;
  9.  
  10. public class ResultadosProva {
  11.  
  12.     public static void main(String[] args) {
  13.        
  14.         Scanner entrada = new Scanner(System.in);
  15.         ArrayList<Integer> notas = new ArrayList<Integer>();
  16.        
  17.         while(true){
  18.             String linha[] = entrada.nextLine().split(" ");
  19.            
  20.             if(linha[0].equals("-")){
  21.                 break;
  22.             }
  23.             else{
  24.                 notas.add(Integer.parseInt(linha[1]));
  25.             }
  26.            
  27.         }
  28.        
  29.         int menor = notas.get(0);
  30.         int maior = notas.get(0);
  31.         int soma = 0;
  32.        
  33.         for(int i=0; i<notas.size() ; i++){
  34.             if(notas.get(i)< menor){
  35.                 menor = notas.get(i);
  36.             }
  37.             if(notas.get(i) > maior){
  38.                 maior = notas.get(i);
  39.             }
  40.             soma += notas.get(i);
  41.         }
  42.        
  43.         float media = soma/notas.size();
  44.        
  45.         int acima = 0;
  46.         int abaixo = 0;
  47.        
  48.         for (int i=0; i<notas.size() ; i++){
  49.             if(notas.get(i) >= 700){
  50.                 acima += 1;
  51.             }
  52.             else {
  53.                 abaixo += 1;
  54.             }
  55.         }
  56.        
  57.         System.out.printf("maior: %d\n",maior);
  58.         System.out.printf("menor: %d\n",menor);
  59.         System.out.printf("media: %.0f\n",media);
  60.         System.out.printf("acima: %d\n",acima);
  61.         System.out.printf("abaixo: %d\n",abaixo);
  62.    
  63.         entrada.close();
  64.     }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement