/Classe aluno/
public class aluno {
private String nome;
private double notaA1, notaA2;
private double mediaAluno;
public void setNome(String nome) {
this.nome = nome;
}
String getNome() {
return this.nome;
}
void setNotaA1(double nota1 ) {
this.notaA1 = nota1;
}
double getNotaA1() {
return this.notaA1;
}
void setNotaA2( double nota2 ) {
this.notaA2 = nota2;
}
double getNotaA2() {
return this.notaA2;
}
void setMedia(double media) {
this.mediaAluno = ( (notaA1 + (2 * notaA2))/3);
}
double getMedia(double mediaAluno) {
return mediaAluno;
}
}
/Media alunos/
import java.text.DecimalFormat;
import java.util.Scanner;
public class mediaAlunos_v001 {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
DecimalFormat decimal = new DecimalFormat("0.0");
aluno nome = new aluno();
aluno notaA1 = new aluno();
aluno notaA2 = new aluno();
aluno mediaAluno = new aluno();
System.out.println("Digite o nome do aluno! ");
nome.setNome(read.nextLine());
//read.nextLine();
System.out.println("Digite a nota A1! ");
notaA1.setNotaA1(read.nextDouble());
System.out.println("Digite a nota A2! ");
notaA2.setNotaA2(read.nextDouble());
System.out.println(nome.getNome());
System.out.println(notaA1.getNotaA1());
System.out.println(notaA2.getNotaA2());
System.out.println(decimal.format( mediaAluno.getMedia()));
read.close();
}
}