• Lenguaje

    Pascal

  • Descripción

    En un municipio de México, se necesita registrar los accidentes que ocurren en una semana, incluyendo identificación del conductor, edad y género.
    Con la información obtenida, se debe obtener:
    a) Porcentaje de conductores menores de edad
    b) Porcentaje de conductores de género femenino
    c) Porcentaje de conductores de género masculino con edades comprendidas entre 19 y 25 años.

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
program RegistroDeAccidentes;
uses crt;

var accidentes, edad, genero : integer;
var a, b, c : real;
var identificacion : string;
var tecla_repetir : char;
begin
    accidentes := 0;
    a := 0;
    b := 0;
    c := 0;
    repeat
        clrscr;
        write ('Ingresa el identificacion: ');
        readln (identificacion);
        write ('Ingresa el valor de edad: ');
        readln (edad);
        writeln ('Selecciona el valor de genero.');
        writeln ('    1.- Femenino');
        writeln ('    2.- Masculino');
        write ('    : ');
        repeat
            readln (genero);
            if (genero<1) or (genero>2) then
                write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
        until (genero>=1) and (genero<=2);
        if edad<18 then
            begin
                a := a+1;
            end;
        if genero=1 then
            begin
                b := b+1;
            end;
        if (edad>=19) and (edad<=25) and (genero=2) then
            begin
                c := c+1;
            end;
        accidentes := accidentes+1;
        writeln ('Identificacion: ', identificacion);
        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');
    if accidentes = 0 then
        a := 0
    else
        a := 100.0*a/accidentes;
    if accidentes = 0 then
        b := 0
    else
        b := 100.0*b/accidentes;
    if accidentes = 0 then
        c := 0
    else
        c := 100.0*c/accidentes;
    writeln ('Valor de accidentes: ', accidentes);
    writeln ('Valor de a: ', a:0:6);
    writeln ('Valor de b: ', b:0:6);
    writeln ('Valor de c: ', c:0:6);
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.