• Lenguaje

    Pascal

  • Descripción

    Un chef quiere calcular costo total de preparar una receta de 5 ingredientes. Ingresar cantidad, precio y nombre de cada ingrediente.

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
program RecetaDe5Ingredientes;
uses crt;

var i : integer;
var cantidad_del_ingrediente, costo_total, precio_del_ingrediente : real;
var nombre_del_ingrediente : string;
begin
    costo_total := 0;
    for i:=1 to 5 do
    begin
        writeln ('PROCESO ', i);
        write ('Ingresa el nombre del ingrediente: ');
        readln (nombre_del_ingrediente);
        write ('Ingresa el valor de cantidad del ingrediente: ');
        readln (cantidad_del_ingrediente);
        write ('Ingresa el valor de precio del ingrediente: ');
        readln (precio_del_ingrediente);
        costo_total := costo_total+precio_del_ingrediente*cantidad_del_ingrediente;
        writeln ('Nombre del ingrediente: ', nombre_del_ingrediente);
        writeln;
    end;
    writeln ('Valor de costo total: ', costo_total:0:6);
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.