• Lenguaje

    Pascal

  • Descripción

    Las autoridades de una universidad necesitan con urgencia el porcentaje de estudiantes que podrían reprobar el semestre. Existe historial donde indica que un estudiante que ha reprobado el semestre es porque trabaja mínimo 8 horas al día, vive a 2 horas de la universidad y normalmente llega tarde a clases.
    Permita calcular lo siguiente:
    - Ingreso de datos.
    - Calcular la cantidad de estudiantes que reprobaran y cantidad que no reprobaran.
    - Calcular y mostrar el porcentaje de estudiantes que reprobaran.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
program PorcentajeDeReprobados;
uses crt;

var cantidad_que_aprobaran, cantidad_que_reprobaran, horas_de_la_universidad, horas_de_trabajo, llega_tarde : integer;
var porcentaje_que_reprobaran : real;
var tecla_repetir : char;
begin
    cantidad_que_aprobaran := 0;
    cantidad_que_reprobaran := 0;
    porcentaje_que_reprobaran := 0;
    repeat
        clrscr;
        write ('Ingresa el valor de horas de la universidad: ');
        readln (horas_de_la_universidad);
        write ('Ingresa el valor de horas de trabajo: ');
        readln (horas_de_trabajo);
        writeln ('Selecciona el valor de llega tarde.');
        writeln ('    1.- Si');
        writeln ('    2.- No');
        write ('    : ');
        repeat
            readln (llega_tarde);
            if (llega_tarde<1) or (llega_tarde>2) then
                write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
        until (llega_tarde>=1) and (llega_tarde<=2);
        if (horas_de_trabajo>=8) and (horas_de_la_universidad>=2) and (llega_tarde=1) then
            begin
                cantidad_que_reprobaran := cantidad_que_reprobaran+1;
            end
        else
            begin
                cantidad_que_aprobaran := cantidad_que_aprobaran+1;
            end;
        writeln;
        write (#168'Deseas repetir el proceso? (S/N): ');
        repeat
            tecla_repetir := readkey;
        until (tecla_repetir = 's') or (tecla_repetir = 'n') or (tecla_repetir = 'S') or (tecla_repetir = 'N');
    until (tecla_repetir <> 's') and (tecla_repetir <> 'S');
    porcentaje_que_reprobaran := 100.0*cantidad_que_reprobaran/(cantidad_que_reprobaran+cantidad_que_aprobaran);
    writeln ('Valor de cantidad que aprobaran: ', cantidad_que_aprobaran);
    writeln ('Valor de cantidad que reprobaran: ', cantidad_que_reprobaran);
    writeln ('Valor de porcentaje que reprobaran: ', porcentaje_que_reprobaran:0:6);
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.