import java.util.Scanner;
class Aluno {
// Atributos
private String nome;
private double nota1;
private double nota2;
private double nota3;
public Aluno(String nome, double nota1, double nota2, double nota3) {
this.nome = nome;
this.nota1 = nota1;
this.nota2 = nota2;
this.nota3 = nota3;
}
public double calcularNotaFinal() {
double notaFinal = nota1 * 30 / 100 + nota2 * 35 / 100 + nota3 * 35 / 100;
return notaFinal;
}
public boolean passou() {
return calcularNotaFinal() >= 60.0;
}
public double pontosFaltando() {
double pontosFaltando = 60.0 - calcularNotaFinal();
return pontosFaltando;
}
public String notaFinalFormatada() {
return String.format("%.2f", calcularNotaFinal());
}
public String situacao() {
if (passou()) {
return "PASS";
} else {
return "FAILED\nMISSING " + String.format("%.2f", pontosFaltando()) + " POINTS";
}
}
}
public class Lista8exerc5 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Digite o nome do aluno:");
String nome = sc.nextLine();
System.out.println("Digite as notas do primeiro, segundo e terceiro trimestre:");
double nota1 = Double.parseDouble(sc.nextLine());
double nota2 = Double.parseDouble(sc.nextLine());
double nota3 = Double.parseDouble(sc.nextLine());
Aluno aluno = new Aluno(nome, nota1, nota2, nota3);
System.out.println("FINAL GRADE = " + aluno.notaFinalFormatada());
System.out.println(aluno.situacao());
sc.close();
}
}
To embed this program on your website, copy the following code and paste it into your website's HTML: