Buscar

Atividade - Estrutura de Dados 1

Prévia do material em texto

CURSO: Análise e desenvolvimento de sistemas 
POLO DE APOIO PRESENCIAL: Higienópolis 
SEMESTRE: 3° semestre 
COMPONENTE CURRICULAR / TEMA: ESTRUTURA DE DADOS 
NOME COMPLETO DO ALUNO: Maria Beatriz da Silva Souza 
TIA: 22516042 
NOME DO PROFESSOR: THIAGO DONIZETTI DOS SANTOS 
 
import java.io.BufferedReader; 
import java.io.FileReader; 
import java.io.IOException; 
import java.util.ArrayList; 
 
public class Main { 
 public static void main(String[] args) { 
 ArrayList<Double> notas = new ArrayList<>(); 
 double somaNotas = 0.0; 
 
 try (BufferedReader br = new BufferedReader(new FileReader("alunos.txt"))) { 
 String linha; 
 while ((linha = br.readLine()) != null) { 
 String[] partes = linha.split(";"); 
 if (partes.length == 3) { 
 double nota = Double.parseDouble(partes[2]); 
 
 notas.add(nota); 
 somaNotas += nota; 
 } 
 } 
 } catch (IOException e) { 
 e.printStackTrace(); 
 } 
 
 if (!notas.isEmpty()) { 
 double media = somaNotas / notas.size(); 
 System.out.println("Média das notas: " + media); 
 System.out.println("Notas maiores ou iguais à média:"); 
 for (Double nota : notas) { 
 if (nota >= media) { 
 System.out.println("Nota acima da média => " + nota); 
 } 
 } 
 System.out.println("Fim do programa."); 
 } else { 
 System.out.println("Nenhuma nota encontrada no arquivo."); 
 } 
 } 
}

Continue navegando