Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions Alunos.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
public class Alunos {
private String nome;
private int matricula;
private float prova1;
private float prova2;
private float trabalho;

private double media;
public Alunos(){
setProva1(-1);
setProva2(-1);
setTrabalho(-1);
}

public void setNome(String nome) {
this.nome = nome;
}

public String getNome() {
return nome;
}

public int getMatricula() {
return matricula;
}

public void setMatricula(int matricula) {
this.matricula = matricula;
}

public float getProva1() {
return prova1;
}

public float getProva2() {
return prova2;
}

public float getTrabalho() {
return trabalho;
}

public void setProva1(float prova1) {
this.prova1 = prova1;
}

public void setProva2(float prova2) {
this.prova2 = prova2;
}

public void setTrabalho(float trabalho) {
this.trabalho = trabalho;
}

public double getMedia() {

if (this.prova1 > -1 && this.prova2 > -1 && this.trabalho > -1) {
this.media = ((this.prova1 * 2.5) + (this.prova2 * 2.5) + (this.trabalho * 2.0))/7.0;

return this.media;
}
else {
return -1;
}
}

public double getFinal() {
if (this.media > 7.0) {
return 0;
}
else {
return (5 - (this.media*0.6))/0.4;
}
}
}
67 changes: 67 additions & 0 deletions Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
import java.util.Scanner;
public class Main {

public static void getNotaAluno(int matricula, Alunos[] alunos){
for (Alunos aluno: alunos
) {
if(aluno.getMatricula() == matricula) {
System.out.printf("O aluno de matriculo %d teve media: %.2f", matricula, aluno.getMedia());
}
}
}

public static void getFinalCountdown(int matricula, Alunos[] alunos) {
for (Alunos aluno: alunos
) {
if(aluno.getMatricula() == matricula) {
System.out.printf("O aluno de matriculo %d precisa tirar %.2f na final para passar", matricula, aluno.getFinal());
}
}
}

public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Alunos[] alunos = new Alunos[2];
int count = 0;

while(count < alunos.length) {
System.out.println("Informe o nome do aluno:");
String nome = input.nextLine();

System.out.println("informe a matricula:");
int matricula = input.nextInt();

System.out.println("informe a nota da primeira prova");
float nota = input.nextFloat();

System.out.println("informe a nota do segundo trabalho:");
float nota2 = input.nextFloat();

System.out.println("Informe a nota do trabalho:");
float trabalho = input.nextFloat();

alunos[count].setNome(nome);
alunos[count].setMatricula(matricula);
alunos[count].setProva1(nota);
alunos[count].setProva2(nota2);
alunos[count].setTrabalho(trabalho);

count++;
}

System.out.println("escolha uma das opções:\n1->ver a media de um aluno\n2->ver quanto um aluno precisa na final");
int opc = input.nextInt();

System.out.println("informe a matricula do aluno");
int matricula = input.nextInt();

switch (opc) {
case 1 -> getNotaAluno(matricula, alunos);
case 2 -> getFinalCountdown(matricula, alunos);
}

}

}