Advertisement
cesarnascimento

ex4 fernando matrizes incompleto

Jun 5th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.02 KB | None | 0 0
  1. package ex;
  2. import java.util.Scanner;
  3. public class ex4 {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner sc = new Scanner(System.in);
  7.         int [][] notas = new int [3][5]; // matriz das notas
  8.         String [] nomes = new String [3]; // vetor dos nomes
  9.        
  10.                 //receber nomes
  11.         for(int i = 0; i < nomes.length; i++){
  12.                 System.out.println("Digite o "+i+"º nome: ");
  13.                 nomes[i] = sc.next();
  14.         }
  15.        
  16.         //receber a nota para as matrizes
  17.         double media = 0;
  18.         for(int i = 0; i < notas.length; i++){
  19.             for(int j = 0; j<notas[i].length; j++){
  20.                 System.out.println("Digite a nota da posição ["+i+","+j+"] :");
  21.                 notas[i][j] = sc.nextInt();
  22.                
  23.                 media = ((notas[i][j]) / 5);
  24.             }
  25.         }
  26.        
  27.         for(int i = 0; i < notas.length; i++){
  28.             for(int j = 0; j < notas[i].length; j++){
  29.                 if(media >= 7){
  30.                     System.out.println("Aluno aprovado.");
  31.                 }else{
  32.                     System.out.println("Aluno reprovado.");
  33.                 }
  34.             }
  35.         }
  36.  
  37.        
  38.         //media das 5 provas
  39.        
  40.        
  41.  
  42.     }
  43.  
  44. }
  45. //Receber notas de 15 alunos em cinco provas diferentes e armazenar em uma matriz 15 x 5.
  46. //Os nomes dos 15 alunos e armazenar em um vetor de 15 posiçoes.
  47. //Mostrar para cada aluno o nome, a media das 5 provas e se foi aprovado ou reprovado.
  48. //A media da classe
  49.  
  50.  
  51.  
  52. package ex;
  53. import java.util.Scanner;
  54.  
  55. public class Questao4 {
  56.  
  57.     public static void main(String[] args) {
  58.         Scanner sc = new Scanner (System.in);
  59.    
  60.         float nota [][] = new float [15][5];
  61.         String vetor [] = new String [15];
  62.         float media [] = new float [15];
  63.        
  64.         //Recebendo os nomes dos alunos
  65.         for (int l = 0; l < 15; l++) {
  66.             System.out.print("Nome do aluno: ");
  67.             vetor[l] = sc.next();
  68.         }
  69.             //Recebendo as notas dos alunos
  70.             for (int l = 0; l < nota.length; l++) {
  71.                 for (int c = 0; c < nota[c].length; c++) {
  72.                 System.out.print("Nota do aluno: ");
  73.                 nota [l][c] = sc.nextFloat();
  74.            
  75.                 }
  76.             }
  77.                 //Media das notas de cada aluno
  78.                 for (int l = 0; l < nota.length; l++) {
  79.                     for (int c = 0; c < nota[c].length; c++) {
  80.                         media[l] += nota[0][c];
  81.                         media[l] += nota[1][c];
  82.                         media[l] += nota[2][c];
  83.                         media[l] += nota[3][c];
  84.                         media[l] += nota[4][c];
  85.                         media[l] += nota[5][c];
  86.                         media[l] += nota[6][c];
  87.                         media[l] += nota[7][c];
  88.                         media[l] += nota[8][c];
  89.                         media[l] += nota[9][c];
  90.                         media[l] += nota[10][c];
  91.                         media[l] += nota[11][c];
  92.                         media[l] += nota[12][c];
  93.                         media[l] += nota[13][c];
  94.                         media[l] += nota[14][c];
  95.                     }
  96.                 }
  97.                 //Situação dos alunos
  98.                 for (int l = 0; l < media.length; l++) {
  99.                     media[l] /= 5;
  100.                    
  101.                         if (media[l] >= 7) {
  102.                             System.out.println("O aluno " + vetor[l] + " tirou " + media[l] + " na média e está aprovado");
  103.                         } else if (media[l] >= 4 && media[l] < 7) {
  104.                             System.out.println("O aluno " + vetor[l] + " tirou " + media[l] + " na média e está no exame");
  105.                         } else if (media[l] < 4) {
  106.                             System.out.println("O aluno " + vetor[l] + " tirou " + media[l] + " na média e está reprovado");
  107.                         }
  108.                 }
  109.                        
  110.     }
  111.  
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement