Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package trabf;
- import java.util.Scanner;
- public class TrabF {
- public static int[] lerPresencas() {
- Scanner sc = new Scanner(System.in);
- int v[] = new int[4];
- System.out.println("Informar presença nos trimestres: ");
- try {
- for (int i = 0; i < 4; i++) {
- System.out.println((i + 1) + "° Trimestre: ");
- v[i] = sc.nextInt();
- while (v[i] < 0 || v[i] > 50) {
- System.out.println("Informar presença valida.");
- v[i] = sc.nextInt();
- }
- }
- }catch (java.util.InputMismatchException e) {
- System.out.println("Informar um valor valido " + e);
- }
- return v;
- }
- public static int[] notasTrm() {
- int v[] = new int[4];
- Scanner sc = new Scanner(System.in);
- System.out.println("Informar nota dos trimestres: ");
- for (int i = 0; i < 4; i++) {
- do {
- System.out.println((i + 1) + "° Trimestre: ");
- v[i] = sc.nextInt();
- if (v[i] < 0) {
- System.out.println("Pontuação invalida, informar pontuação valida");
- }
- } while (v[i] < 0);
- if (i == 1 || i == 3) {
- while (v[i] > 30) {
- System.out.println("Pontuação maxima excedida,informe pontuação valida.");
- v[i] = sc.nextInt();
- }
- } else {
- while (v[i] > 20) {
- System.out.println("Pontuação maxima excedida,informe pontuação valida.");
- v[i] = sc.nextInt();
- }
- }
- }
- return v;
- }
- public static int semestre1(int notasTrim[][], int qAlunos, int notasFinaisSem[][]) {
- Scanner sc = new Scanner(System.in);
- int notaRec = 0;
- int somaNotasSemestre1 = notasTrim[qAlunos][0] + notasTrim[qAlunos][1];
- System.out.println("Soma das notas do primeiro semestre: " + somaNotasSemestre1 + " pontos");
- if (somaNotasSemestre1 >= 30) {
- notasFinaisSem[qAlunos][0] = somaNotasSemestre1;
- System.out.println("Pontuação no semestre: " + notasFinaisSem[qAlunos][0]);
- return 0;
- } else {
- System.out.println("Recuperação 1o semestre.");
- System.out.println("Informar nota do exame de recuperação: ");
- notaRec = sc.nextInt();
- while (notaRec < 0 || notaRec > 50) {
- System.out.println("Pontuação invalida,informar pontuação valida");
- notaRec = sc.nextInt();
- }
- if (notaRec >= 30) {
- notasFinaisSem[qAlunos][0] = 30;
- System.out.println("Pontuação no primeiro semestre: " + notasFinaisSem[qAlunos][0]);
- } else if (notaRec > somaNotasSemestre1) {
- notasFinaisSem[qAlunos][0] = notaRec;
- System.out.println("Pontuação no semestre: " + notasFinaisSem[qAlunos][0]);
- } else if (notaRec < somaNotasSemestre1) {
- notasFinaisSem[qAlunos][0] = somaNotasSemestre1;
- System.out.println("Pontuação no primeiro semestre: " + notasFinaisSem[qAlunos][0]);
- }
- while (notaRec < 0 || notaRec > 50) {
- System.out.println("Pontuação invalida,informar pontuação valida");
- notaRec = sc.nextInt();
- }
- return 1;
- }
- }
- public static int semestre2(int notasTrim[][], int qAlunos, int notasFinaisSem[][]) {
- Scanner sc = new Scanner(System.in);
- int notaRec = 0;
- int somaNotasSemestre2 = notasTrim[qAlunos][2] + notasTrim[qAlunos][3];
- System.out.println("Soma das notas do segundo semestre: " + somaNotasSemestre2 + " pontos");
- if (somaNotasSemestre2 >= 30) {
- notasFinaisSem[qAlunos][1] = somaNotasSemestre2;
- return 0;
- } else {
- System.out.println("Recuperação 2o semestre.");
- System.out.println("Informar nota do exame de recuperação do segundo semestre: ");
- notaRec = sc.nextInt();
- while (notaRec < 0 || notaRec > 50) {
- System.out.println("Pontuação inválida,informar pontuação válida");
- notaRec = sc.nextInt();
- }
- if (notaRec >= 30) {
- notasFinaisSem[qAlunos][1] = 30;
- System.out.println("Pontuação no segundo semestre: " + notasFinaisSem[qAlunos][1]);
- } else if (notaRec > somaNotasSemestre2) {
- notasFinaisSem[qAlunos][1] = notaRec;
- System.out.println("Pontuação no segundo semestre: " + notasFinaisSem[qAlunos][1]);
- } else if (notaRec < somaNotasSemestre2) {
- notasFinaisSem[qAlunos][1] = somaNotasSemestre2;
- System.out.println("Pontuação no segundo semestre: " + notasFinaisSem[qAlunos][1]);
- }
- return 1;
- }
- }
- public static int recFinal(int notasFinaisSem[][], int notasTrim[][], int qAlunos, int somaNotaFinal) {
- Scanner sc = new Scanner(System.in);
- int notaRec = 0;
- int somaNotasSem1 = 0;
- int somaNotasSem2 = 0;
- somaNotaFinal = notasFinaisSem[qAlunos][0] + notasFinaisSem[qAlunos][1];
- if (somaNotaFinal >= 40 && somaNotaFinal < 60) {
- System.out.println("Recuperação FINAL.");
- System.out.println("Informar nota da recuperação: ");
- notaRec = sc.nextInt();
- while (notaRec < 0 || notaRec > 100) {
- System.out.println("Informar pontuação valida: ");
- notaRec = sc.nextInt();
- }
- if (notaRec >= 60) {
- somaNotaFinal = 60;
- } else if (notaRec > somaNotaFinal) {
- somaNotaFinal = notaRec;
- }
- return somaNotaFinal;
- } else {
- return -1;
- }
- }
- public static int aprovSe(int presenca, int notaFinal) {
- if (notaFinal >= 60 && presenca >= 75) {
- System.out.println("Aprovado: " + notaFinal + " pontos" + ", " + " presença: " + presenca + "%");
- return 1;
- } else if (notaFinal >= 75 && presenca >= 50) {
- System.out.println("Aprovado: " + notaFinal + " pontos," + "presença: " + presenca + "%");
- return 1;
- } else {
- System.out.println("Reprovado: " + notaFinal + " pontos" + ", " + " presença: " + presenca + "%");
- return 0;
- }
- }
- public static void imprimir(int notasTrim[][]) {
- System.out.println("Relatório Final: ");
- System.out.println("T1\tT2\tT3\tT4\t");
- for (int a = 0; a < notasTrim.length; a++) {
- for (int t = 0; t < notasTrim[0].length; t++) {
- System.out.print(notasTrim[a][t] + "\t");
- }
- System.out.println();
- }
- }
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int somaNotasSemestre1 = 0, alunosRecSem = 0, alunosRecFinal = 0, notaFinal = 0;
- int somaNotasSem1 = 0, somaNotaFinal = 0;
- int n = 0;
- try {
- System.out.println("Informar quantidade de alunos: ");
- n = sc.nextInt();
- while (n < 0) {
- System.out.println("Informar quantidade de alunos: ");
- n = sc.nextInt();
- }
- int notasTrim[][] = new int[n][4];
- int presenca[][] = new int[n][4];
- int notasFinaisSem[][] = new int[n][2];
- int somaNotasSemestre2 = 0;
- String situacao[] = new String[n];
- int somaNotasSem2 = 0;
- int apv = 0;
- int rpv = 0;
- for (int qAlunos = 0; qAlunos < n; qAlunos++) {
- System.out.println("Informar nome: ");
- String nome = sc.next();
- notasTrim[qAlunos] = notasTrm();
- presenca[qAlunos] = lerPresencas();
- int recuperacao = semestre1(notasTrim, qAlunos, notasFinaisSem); // Verifica Recuperacao Sem 1
- if (recuperacao == 1) {
- }
- recuperacao = semestre2(notasTrim, qAlunos, notasFinaisSem); // Verifica Recuperacao Sem 2
- if (recuperacao == 1) {
- }
- int rFinal = recFinal(notasFinaisSem, notasTrim, qAlunos, somaNotaFinal);
- if (rFinal != -1) {
- alunosRecFinal++;
- notaFinal = rFinal;
- } else {
- notaFinal = notasFinaisSem[qAlunos][0] + notasFinaisSem[qAlunos][1];
- }
- double somaPres = presenca[qAlunos][0] + presenca[qAlunos][1] + presenca[qAlunos][2] + presenca[qAlunos][3];
- somaPres = (Math.round((somaPres * 100) / 200));
- int s = (int) somaPres;
- int ap = aprovSe(s, notaFinal);
- if (ap == 1) {
- situacao[qAlunos] = nome + "APROVADO";
- apv++;
- } else {
- situacao[qAlunos] = nome + "REPROVADO";
- rpv++;
- }
- }
- imprimir(notasTrim);
- System.out.println("Alunos aprovados: " + apv + " aluno(s)");
- System.out.println("Alunos de recuperação final: " + alunosRecFinal + " aluno(s)");
- System.out.println("Alunos reprovados: " + rpv + " aluno(s)");
- } catch (java.util.InputMismatchException e) {
- System.out.println("Informar um valor valido." + e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement