-
Lenguaje
Pascal
-
Descripción
Se realizaron 30 encuestas para determinar cuál sabor de yogurt se vende más en el Norte de Bogotá, entre fresa, mora y melocotón, con estos datos se quiere encontrar el porcentaje de cada sabor frente al total. Se debe ingresar lo que respondió cada encuestado e ir incrementando uno a uno el sabor elegido por cada uno.
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
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
program EncuestasDeSaborDeYogurt;
uses crt;
var i, sabor_elegido, sabor_fresa, sabor_melocoton, sabor_mora : integer;
var porcentaje_fresa, porcentaje_melocoton, porcentaje_mora : real;
begin
sabor_fresa := 0;
sabor_melocoton := 0;
sabor_mora := 0;
porcentaje_fresa := 0;
porcentaje_melocoton := 0;
porcentaje_mora := 0;
for i:=1 to 30 do
begin
writeln ('PROCESO ', i);
writeln ('Selecciona el valor de sabor elegido.');
writeln (' 1.- Fresa');
writeln (' 2.- Mora');
writeln (' 3.- Melocot'#162'n');
write (' : ');
repeat
readln (sabor_elegido);
if (sabor_elegido<1) or (sabor_elegido>3) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (sabor_elegido>=1) and (sabor_elegido<=3);
if sabor_elegido=1 then
begin
sabor_fresa := sabor_fresa+1;
end;
if sabor_elegido=2 then
begin
sabor_mora := sabor_mora+1;
end;
if sabor_elegido=3 then
begin
sabor_melocoton := sabor_melocoton+1;
end;
writeln;
end;
porcentaje_fresa := 10.0*sabor_fresa/3;
porcentaje_melocoton := 10.0*sabor_melocoton/3;
porcentaje_mora := 10.0*sabor_mora/3;
writeln ('Valor de sabor fresa: ', sabor_fresa);
writeln ('Valor de sabor melocoton: ', sabor_melocoton);
writeln ('Valor de sabor mora: ', sabor_mora);
writeln ('Valor de porcentaje fresa: ', porcentaje_fresa:0:6);
writeln ('Valor de porcentaje melocoton: ', porcentaje_melocoton:0:6);
writeln ('Valor de porcentaje mora: ', porcentaje_mora:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var i, sabor_elegido, sabor_fresa, sabor_melocoton, sabor_mora : integer;
var porcentaje_fresa, porcentaje_melocoton, porcentaje_mora : real;
begin
sabor_fresa := 0;
sabor_melocoton := 0;
sabor_mora := 0;
porcentaje_fresa := 0;
porcentaje_melocoton := 0;
porcentaje_mora := 0;
for i:=1 to 30 do
begin
writeln ('PROCESO ', i);
writeln ('Selecciona el valor de sabor elegido.');
writeln (' 1.- Fresa');
writeln (' 2.- Mora');
writeln (' 3.- Melocot'#162'n');
write (' : ');
repeat
readln (sabor_elegido);
if (sabor_elegido<1) or (sabor_elegido>3) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (sabor_elegido>=1) and (sabor_elegido<=3);
if sabor_elegido=1 then
begin
sabor_fresa := sabor_fresa+1;
end;
if sabor_elegido=2 then
begin
sabor_mora := sabor_mora+1;
end;
if sabor_elegido=3 then
begin
sabor_melocoton := sabor_melocoton+1;
end;
writeln;
end;
porcentaje_fresa := 10.0*sabor_fresa/3;
porcentaje_melocoton := 10.0*sabor_melocoton/3;
porcentaje_mora := 10.0*sabor_mora/3;
writeln ('Valor de sabor fresa: ', sabor_fresa);
writeln ('Valor de sabor melocoton: ', sabor_melocoton);
writeln ('Valor de sabor mora: ', sabor_mora);
writeln ('Valor de porcentaje fresa: ', porcentaje_fresa:0:6);
writeln ('Valor de porcentaje melocoton: ', porcentaje_melocoton:0:6);
writeln ('Valor de porcentaje mora: ', porcentaje_mora:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.