Guest User

Untitled

a guest
Oct 19th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. package lp2.lab01;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /*
  6. * Laboratório de Programação II - LAB 01
  7. * @author: Fagner Henrique dos Santos Lima - 117110503
  8. */
  9.  
  10. public class AlunosNotas {
  11. public static void main(String[] args) {
  12. Scanner input = new Scanner(System.in);
  13. int[] notas = new int[100];
  14. int menor, maior, acima = 0, abaixo = 0, media = 0, qtd = 0, i;
  15.  
  16. while(true) {
  17. String[] relatorio = input.nextLine().split(" ");
  18. if (relatorio[0].equals("-")){
  19. break;
  20. }
  21. notas[qtd] = Integer.parseInt(relatorio[1]);
  22. qtd++;
  23. }
  24.  
  25. menor = notas[0];
  26. maior = notas[0];
  27.  
  28. for (i = 0; i < qtd; i++) {
  29. media += notas[i];
  30.  
  31. if(notas[i] > maior){
  32. maior = notas[i];
  33. } else if (notas[i] < menor) {
  34. menor = notas[i];
  35. }
  36.  
  37. if(notas[i] >= 700){
  38. acima++;
  39. } else if (notas[i] < 700) {
  40. abaixo++;
  41. }
  42. }
  43.  
  44. media /= qtd;
  45.  
  46. System.out.println("maior: " + maior);
  47. System.out.println("menor: " + menor);
  48. System.out.println("media: " + media);
  49. System.out.println("acima: " + acima);
  50. System.out.println("abaixo: " + abaixo);
  51.  
  52. }
  53. }
Add Comment
Please, Sign In to add comment