Advertisement
LightProgrammer000

Notas [matriz]

Apr 8th, 2020
598
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.18 KB | None | 0 0
  1. /*
  2. //////       Provas
  3. Alunos  1   2   3   4   5
  4.  
  5. 1       3   4   6   8   9
  6. 2       9   5   6   7   8
  7. 3       3   4   6   8   1
  8. 4       6   3   6   7   8
  9. 5       9   8   1   2   4
  10. 6       2   5   6   8   9
  11. 7       1   2   3   4   5
  12. 8       1   5   7   8   9
  13. 9       4   8   9   0   1
  14. 11      5   7   9   0   9
  15. 12      5   7   9   0   9
  16. 13      5   7   9   0   9
  17. 14      5   7   9   0   9
  18. 15      5   7   9   0   9
  19. */
  20. package Tarefas_3;
  21.  
  22. import java.util.Scanner;
  23.  
  24. public class EX_05
  25. {
  26.     public static void main(String[] args)
  27.     {
  28.         // Variaveis
  29.         int num = 0;
  30.         int soma = 0;
  31.        
  32.         // Matriz
  33.         int linha = 15;
  34.         int coluna = 5;
  35.         double nota_matriz [][] = new double [linha][coluna];
  36.        
  37.         // Vetor
  38.         double aluno_med [] = new double [linha];
  39.         String aluno_result [] = new String [linha];
  40.        
  41.         // Vetor: Lista
  42.         String lista_nome[] = {"A", "B", "C", "D", "E",
  43.                                "F", "G", "H", "I", "J",
  44.                                "K", "L", "M", "N", "O"};
  45.  
  46.         String list_aprov[] = {"Aprovado",
  47.                                "Recuperacao",
  48.                                "Reprovado"};
  49.  
  50.         // Instanciacao
  51.         Scanner ent = new Scanner(System.in);
  52.        
  53.         // Estrutura de repeticao: Populacao da matriz
  54.         System.out.println("---------------- Alunos ----------------");
  55.         for (int i = 0; i < linha; i++)
  56.         {
  57.             soma = 0;
  58.             System.out.printf("\n* %d) Aluno: %s\n", (i+1), lista_nome[i]);
  59.  
  60.             for (int j = 0; j < coluna; j++)
  61.             {
  62.                 System.out.printf("# Nota da Prova [%d]: ", j+1);
  63.                 nota_matriz[i][j] = ent.nextDouble();
  64.                
  65.                 soma += nota_matriz[i][j];
  66.             }
  67.            
  68.             // Calculo: Media dos alunos
  69.             aluno_med[i] = (double) soma / coluna;
  70.            
  71.             // Estruturas de decisao: Resultado da aprovacao
  72.             if (aluno_med[i] >= 7)
  73.             {
  74.                 aluno_result[i] = list_aprov[0];
  75.             }
  76.  
  77.             else if (aluno_med[i] > 2 && aluno_med[i] < 7)
  78.             {
  79.                 aluno_result[i] = list_aprov[1];                
  80.             }
  81.            
  82.             else
  83.             {
  84.                 aluno_result[i] = list_aprov[2];
  85.             }
  86.         }
  87.  
  88.         // Estrutura de repeticao: Exibicao da matriz
  89.         System.out.println("\n--------------------------------------------------");
  90.         System.out.println("---------------- Notas das Provas ----------------");
  91.         System.out.println("--------------------------------------------------\n");
  92.        
  93.         for (int i = 0; i < linha; i++)
  94.         {
  95.             System.out.printf("=> Aluno %s", lista_nome[i]);
  96.            
  97.             for (int j = 0; j < coluna; j++)
  98.             {
  99.                 System.out.printf("\n# Nota da Prova [%d]: %.2f", j+1, nota_matriz[i][j]);
  100.             }
  101.            
  102.             System.out.printf("\n# Media geral: %.2f", aluno_med[i]);
  103.             System.out.printf("\n# Resultado: %s \n\n", aluno_result[i]);
  104.         }
  105.     }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement