sábado, 27 de setembro de 2014

Algoritmo para ler o nome, sexo ("M" =Masculino e "F"=Feminino), três notas e o número de faltas dos alunos de uma turma, onde o Flag será um nome igual a "fim" e escrever: a. A média e a situação final de cada aluno; b. A média das notas dos homens e a média das notas das mulheres; c. O percentual de homem e o percentual de mulheres reprovados; d. O percentual geral de reprovação da turma





//Faça um algoritmo para ler o nome, sexo ("M" =Masculino e "F"=Feminino), três notas e o número

//de faltas dos alunos de uma turma, onde o Flag será um nome igual a "fim" e escrever:

//a. A média e a situação final de cada aluno;

//b. A média das notas dos homens e a média das notas das mulheres;

//c. O percentual de homem e o percentual de mulheres reprovados;

//d. O percentual geral de reprovação da turma

program SexoNotasFaltasFlagFim;

uses crt;

type

escola=record

nome:string;

sexo:char;

nota1,nota2,nota3,media:real;

falta:integer;

sit:string;

end;

var

aluno:array[1..1000]of escola;

flag:string;

i,j,q:integer;

somah,somaM,media,qmr,qhr:real;

begin

writeln(' ------ Uma turma escolar -------');

writeln('media: 5.0 falta:27 ');

flag:='naofim';

i:=0;

while (flag <> 'fim') do

begin

i:=i+1;

writeln('_____________ ALUNO ',i,' _____________');

writeln('==> Informe "fim" ou o NOME do aluno:');

readln(aluno[i].nome);

flag:=aluno[i].nome;

if flag<>'fim' then

begin

writeln('==> Informe o sexo do aluno M ou F:');

repeat

aluno[i].sexo:=readkey;

until (aluno[i].sexo = 'M') or (aluno[i].sexo='F') or (aluno[i].sexo = 'm') or (aluno[i].sexo='f');

writeln('==> Informe as 3 notas do aluno:');

readln(aluno[i].nota1,aluno[i].nota2,aluno[i].nota3);

writeln('==> Informe o numero de faltas do aluno:');

readln(aluno[i].falta);

end;

end;

//a. A média e a situação final de cada aluno;

if (i>1) then

begin

clrscr;

writeln(' ------------ A media e a situacao final de cada aluno -----------');

for j:=1 to i-1 do

begin

aluno[j].media:=(aluno[j].nota1 + aluno[j].nota2 + aluno[j].nota3)/3;

if (aluno[j].media>= 5) and (aluno[j].falta<=27) then

begin

aluno[j].sit:='AP';

end else begin

if (aluno[j].media>= 5) and (aluno[j].falta>27) then

begin

aluno[j].sit:='RF';

end else begin

aluno[j].sit:='RM';

end;

end;

writeln('nome:',aluno[j].nome,' media:',aluno[j].media,' situacao:',aluno[j].sit);

end;

//b. A média das notas dos homens e a média das notas das mulheres;

writeln('--- media das notas dos homens e media das notas das mulheres ----');

q:=0;

somah:=0; somaM:=0; qhr:=0; qmr:=0;

for j:= 1 to i-1 do

begin

if (aluno[j].sexo ='m') or (aluno[j].sexo ='M') then

begin

q:=q+1;

somah:=somah + aluno[j].media;

if (aluno[j].sit='RM') or (aluno[j].sit ='RF') then

begin

qhr:= qhr + 1;

end;

end else begin

somaM:=somaM + aluno[j].media;

if (aluno[j].sit='RM') or (aluno[j].sit ='RF') then

begin

qmr:=qmr +1;

end;

end;

end;

if (q <> 0)then

begin

media:= somah /q;

writeln(' Homens:', media);

end else begin

writeln(' Homens: nao existe homem na turma');

end;

if (i-1-q)<>0 then

begin

media:=somaM/(i - 1 - q);

writeln(' Mulheres:',media);

end else begin

writeln(' Mulheres: nao existe mulher na turma');

end;

//c. O percentual de homem e o percentual de mulheres reprovados;

writeln(' -------------- percentual de reprovacoes -----------------------------');

if (q <> 0)then

begin

writeln(' Homens:',(qhr/q)*100);

end else begin

writeln(' Homens: nao existe homem na turma');

end;

if (i-1-q)<>0 then

begin

writeln(' Mulheres:',((qmr)/(i-1-q)*100));

end else begin

writeln(' Mulheres: nao existe mulher na turma');

end;

// d. O percentual geral de reprovação da turma.

writeln(' ------------ percentual geral de reprovacoes ------------ ');

writeln(' percentual =',((qhr + qmr)/(i-1))*100);

writeln('___________________________________________________________________________');

readkey;

end;

end.

Nenhum comentário:

Postar um comentário

Pascal - Lazarus