Ramos123 Posted October 19, 2016 at 01:06 PM Report #599730 Posted October 19, 2016 at 01:06 PM Boa tarde estou aqui com um problema em meter este programa funcionar o programa tem de imprimir dez alunos com resultado do teste 1 e teste 2 e a media dois testes . Também preciso de ajuda a fazer uma tabela onde tem aparecer escrito em cima dos nome dos alunos e as notas deles ,Nome do Aluno ,nota do teste1,nota do teste 2 , classificação final. Se me alguém puder ajudar ficaria muito grato Precisava mesmo de ajuda Se pudessem dar exemplos de como fazer uma tabela também era uma boa ajuda mas o principal era conseguir meter este programa a funcionar . Class Program . using System.Collections; namespace ex1 { class Program { static void Main(string[] args) { ArrayList turma = new ArrayList(); EstudanteInf estundante = new EstudanteInf("joao Ramos", 20, 15); turma.Add(estundante); estundante = new EstudanteInf("tiago", 15, 16); turma.Add(estundante); estundante = new EstudanteInf("andre", 13, 13); turma.Add(estundante); estundante = new EstudanteInf("pedro", 13, 13); turma.Add(estundante); estundante = new EstudanteInf("diogo", 13, 15); turma.Add(estundante); estundante = new EstudanteInf("goncalo", 13, 16); turma.Add(estundante); estundante = new EstudanteInf("bruno", 13, 17); turma.Add(estundante); estundante = new EstudanteInf("francisco", 13, 18); turma.Add(estundante); estundante = new EstudanteInf("andre", 13, 19); turma.Add(estundante); estundante = new EstudanteInf("pascoal", 8, 3); turma.Add(estundante); estundante = new EstudanteInf("afonso", 9, 5); turma.Add(estundante); foreach (EstudanteInf value in turma) { if (value.situacaoDoAluno().Equals("Aprovado")) { value.imprimir(); } } System.Console.WriteLine(); System.Console.Read(); } } } Class EstudanteInf using System; namespace ex1 { class EstudanteInf { string Nome; Double Teste1; Double Teste2; private string p; public EstudanteInf(string NomeDoAluno, Double NotaTeste1, Double NotaTeste2) { Nome = NomeDoAluno; Teste1 = NotaTeste1; Teste2 = NotaTeste2; } public EstudanteInf(string p) { // TODO: Complete member initialization this.p = p; } public Double classFinal() { Double media = (Teste1 + Teste2) / 2; return media; } public string lerNome() { return Nome; } public void escreveNome(string NomeDoAluno) { Nome = NomeDoAluno; } public void escrevenotaTeste1(Double notaTeste1) { Teste1 = notaTeste1; } public void escrevenotaTeste2(Double notaTeste2) { Teste2 = notaTeste2; } public void imprimir(Double classificacaoFinal) { System.Console.WriteLine("| " + lerNome() + " | " + Teste1 + " | " + Teste2 + " | " + classFinal()); } public string situacaoDoAluno() { double classificacaoFinal = classFinal(); if (classificacaoFinal >= 10) { return "Aprovado"; } else { if (classificacaoFinal >= 8) return "Admitido a oral"; else { return "reprovado"; } } } internal void imprimir() { throw new NotImplementedException(); } } }
ribeiro55 Posted October 19, 2016 at 01:50 PM Report #599731 Posted October 19, 2016 at 01:50 PM Certo. E qual é o problema? O que já tentaste e que resultados estás a obter? Repara que tens duas assinaturas para o imprimir, e estás a usar precisamente a que não está implementada. Sérgio Ribeiro "Great coders aren't born. They're compiled and released""Expert coders do not need a keyboard. They just throw magnets at the RAM chips"
apocsantos Posted October 19, 2016 at 01:53 PM Report #599733 Posted October 19, 2016 at 01:53 PM Boa tarde, using System.Collections; namespace ex1 { class Program { static void Main(string[] args) { ArrayList turma = new ArrayList(); EstudanteInf estundante = new EstudanteInf("joao Ramos", 20, 15); turma.Add(estundante); estundante = new EstudanteInf("tiago", 15, 16); turma.Add(estundante); estundante = new EstudanteInf("andre", 13, 13); turma.Add(estundante); estundante = new EstudanteInf("pedro", 13, 13); turma.Add(estundante); estundante = new EstudanteInf("diogo", 13, 15); turma.Add(estundante); estundante = new EstudanteInf("goncalo", 13, 16); turma.Add(estundante); estundante = new EstudanteInf("bruno", 13, 17); turma.Add(estundante); estundante = new EstudanteInf("francisco", 13, 18); turma.Add(estundante); estundante = new EstudanteInf("andre", 13, 19); turma.Add(estundante); estundante = new EstudanteInf("pascoal", 8, 3); turma.Add(estundante); estundante = new EstudanteInf("afonso", 9, 5); turma.Add(estundante); //imprime cabecalho Console.WriteLine("╔═════════════════════════════════╦═══════════╦══════════╦═══════════════════════════╗"); Console.WriteLine("║ Nome ║ Teste 1 ║ Teste 2 ║ Classificação Final ║"); Console.WriteLine("╠═════════════════════════════════╬═══════════╬══════════╬═══════════════════════════╣"); foreach (EstudanteInf value in turma) { string toPrint = "║" + Value.lernome() + Value.lerTeste1() + Value.lerTeste2() + Value.classFinal() + "║"; } //imprime a ultima linha Console.WriteLine("╚═════════════════════════════════╩═══════════╩══════════╩═══════════════════════════╝"); // System.Console.WriteLine(); System.Console.Read(); } } } Class using System; namespace ex1 { class EstudanteInf { string Nome; Double Teste1; Double Teste2; private string p; public EstudanteInf(string NomeDoAluno, Double NotaTeste1, Double NotaTeste2) { Nome = NomeDoAluno; Teste1 = NotaTeste1; Teste2 = NotaTeste2; } public EstudanteInf(string p) { // TODO: Complete member initialization this.p = p; } public Double classFinal() { Double media = (Teste1 + Teste2) / 2; return media; } public string lerNome() { return Nome; } public string lerTeste1() { return Teste1.toString(); } public string lerTeste2() { return Teste2.toString(); } public void escreveNome(string NomeDoAluno) { Nome = NomeDoAluno; } public void escrevenotaTeste1(Double notaTeste1) { Teste1 = notaTeste1; } public void escrevenotaTeste2(Double notaTeste2) { Teste2 = notaTeste2; } public string situacaoDoAluno() { double classificacaoFinal = classFinal(); if (classificacaoFinal >= 10) { return "Aprovado"; } else { if (classificacaoFinal >= 8) return "Admitido a oral"; else { return "reprovado"; } } } internal void imprimir() { throw new NotImplementedException(); } } } Ainda podes optimizar imenso o código e por exemplo colocar uma validação para o nome dar o numero exacto de caracteres para obteres a "grelha" toda formatada correctamente, mas isso é um bom exercício para tu fazeres! Cordiais cumprimentos, Apocsantos 1 Report "A paciência é uma das coisas que se aprendeu na era do 48k" O respeito é como a escrita de código, uma vez perdido, dificilmente se retoma o habito"
Ramos123 Posted October 19, 2016 at 02:50 PM Author Report #599736 Posted October 19, 2016 at 02:50 PM Obrigado pela ajuda amigo
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now