forked from maniero/SOpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMedia.java
More file actions
33 lines (28 loc) · 743 Bytes
/
Copy pathMedia.java
File metadata and controls
33 lines (28 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class HelloWorld {
public static void main (String[] args) {
Aluno aluno = new Aluno("joao", 1, 8f, 6f);
aluno.exibir();
}
}
class Aluno {
private String nome;
private int matricula;
private float n1, n2;
public Aluno(String nome, int matricula, float n1, float n2) {
this.nome = nome;
this.matricula = matricula;
this.n1 = n1;
this.n2 = n2;
}
public float media() {
return (n1 + n2) / 2;
}
public void exibir() {
System.out.println("Nome:" +nome);
System.out.println("Matrícula:" + matricula);
System.out.println("Nota 1:" + n1);
System.out.println("Nota 2:" + n2);
System.out.println("A média é:" + media());
}
}
//https://pt.stackoverflow.com/q/204494/101