Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ex;
- import java.util.Scanner;
- public class ex4 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int [][] notas = new int [3][5]; // matriz das notas
- String [] nomes = new String [3]; // vetor dos nomes
- //receber nomes
- for(int i = 0; i < nomes.length; i++){
- System.out.println("Digite o "+i+"º nome: ");
- nomes[i] = sc.next();
- }
- //receber a nota para as matrizes
- double media = 0;
- for(int i = 0; i < notas.length; i++){
- for(int j = 0; j<notas[i].length; j++){
- System.out.println("Digite a nota da posição ["+i+","+j+"] :");
- notas[i][j] = sc.nextInt();
- media = ((notas[i][j]) / 5);
- }
- }
- for(int i = 0; i < notas.length; i++){
- for(int j = 0; j < notas[i].length; j++){
- if(media >= 7){
- System.out.println("Aluno aprovado.");
- }else{
- System.out.println("Aluno reprovado.");
- }
- }
- }
- //media das 5 provas
- }
- }
- //Receber notas de 15 alunos em cinco provas diferentes e armazenar em uma matriz 15 x 5.
- //Os nomes dos 15 alunos e armazenar em um vetor de 15 posiçoes.
- //Mostrar para cada aluno o nome, a media das 5 provas e se foi aprovado ou reprovado.
- //A media da classe
- package ex;
- import java.util.Scanner;
- public class Questao4 {
- public static void main(String[] args) {
- Scanner sc = new Scanner (System.in);
- float nota [][] = new float [15][5];
- String vetor [] = new String [15];
- float media [] = new float [15];
- //Recebendo os nomes dos alunos
- for (int l = 0; l < 15; l++) {
- System.out.print("Nome do aluno: ");
- vetor[l] = sc.next();
- }
- //Recebendo as notas dos alunos
- for (int l = 0; l < nota.length; l++) {
- for (int c = 0; c < nota[c].length; c++) {
- System.out.print("Nota do aluno: ");
- nota [l][c] = sc.nextFloat();
- }
- }
- //Media das notas de cada aluno
- for (int l = 0; l < nota.length; l++) {
- for (int c = 0; c < nota[c].length; c++) {
- media[l] += nota[0][c];
- media[l] += nota[1][c];
- media[l] += nota[2][c];
- media[l] += nota[3][c];
- media[l] += nota[4][c];
- media[l] += nota[5][c];
- media[l] += nota[6][c];
- media[l] += nota[7][c];
- media[l] += nota[8][c];
- media[l] += nota[9][c];
- media[l] += nota[10][c];
- media[l] += nota[11][c];
- media[l] += nota[12][c];
- media[l] += nota[13][c];
- media[l] += nota[14][c];
- }
- }
- //Situação dos alunos
- for (int l = 0; l < media.length; l++) {
- media[l] /= 5;
- if (media[l] >= 7) {
- System.out.println("O aluno " + vetor[l] + " tirou " + media[l] + " na média e está aprovado");
- } else if (media[l] >= 4 && media[l] < 7) {
- System.out.println("O aluno " + vetor[l] + " tirou " + media[l] + " na média e está no exame");
- } else if (media[l] < 4) {
- System.out.println("O aluno " + vetor[l] + " tirou " + media[l] + " na média e está reprovado");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement