Advertisement
estevaorada

Aluno.cs

Apr 16th, 2025
278
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. using System;
  2.  
  3. public class Aluno
  4. {
  5.     // Atributos da classe
  6.     private string nome;
  7.     private int matricula;
  8.     private double nota1;
  9.     private double nota2;
  10.     private string curso;
  11.  
  12.     // Construtor
  13.     public Aluno(string nome, int matricula, double nota1, double nota2, string curso)
  14.     {
  15.         this.nome = nome;
  16.         this.matricula = matricula;
  17.         this.nota1 = nota1;
  18.         this.nota2 = nota2;
  19.         this.curso = curso;
  20.     }
  21.  
  22.     // Métodos que retornam dados
  23.     public string GetNome()
  24.     {
  25.         return nome;
  26.     }
  27.  
  28.     public int GetMatricula()
  29.     {
  30.         return matricula;
  31.     }
  32.  
  33.     public double GetNota1()
  34.     {
  35.         return nota1;
  36.     }
  37.  
  38.     public double GetNota2()
  39.     {
  40.         return nota2;
  41.     }
  42.  
  43.     public string GetCurso()
  44.     {
  45.         return curso;
  46.     }
  47.  
  48.     public double CalcularMedia()
  49.     {
  50.         return (nota1 + nota2) / 2;
  51.     }
  52.  
  53.     public string SituacaoAluno()
  54.     {
  55.         double media = CalcularMedia();
  56.         return media >= 7 ? "Aprovado" : "Reprovado";
  57.     }
  58.  
  59.     public string DadosCompletos()
  60.     {
  61.         return $"Nome: {nome}, Matrícula: {matricula}, Curso: {curso}";
  62.     }
  63.  
  64.     public string NotasFormatadas()
  65.     {
  66.         return $"Nota 1: {nota1}, Nota 2: {nota2}";
  67.     }
  68.  
  69.     public string MediaFormatada()
  70.     {
  71.         return $"Média: {CalcularMedia():F2}";
  72.     }
  73. }
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement