Controla el contenido productos en una bodega
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | {-Victor De la Rocha} {-Algoritmia@groups.msn.com} {-www.myalgorithm.com} {Programa que lee mercancias; su precio, cantidad y hace informes}uses crt; const max=100; type item=record articulo:string; precio:real; cantidad:integer; end; datos=array [1..max] of item; var inventario:datos; opc,cantidad,c:integer; res:string[1]; {funcion que centra el titulo en la pantalla} function titulo(titulo:string):integer; begin gotoxy(Trunc((80/2)-(length(titulo)/2)),1);Write(titulo); end; begin {inicializo las variables} cantidad:=1; repeat ClrScr; {imprimo el titulo del menu} titulo('Inventario de articulos'); writeln; writeln; {imprimo el menu} Writeln(' 1.-Agregar producto'); Writeln(' 2.-Reporte de existencias'); Writeln(' 3.-Salir'); {pido la opcion del menu} writeln; {insistir en que introdusca una opcion existente y correcta} Write(' -> Opcion: ');Readln(opc); case opc of 1:{introducir productos} begin for cantidad:=cantidad to max do begin ClrScr; titulo('Agregar productos'); writeln; writeln; write(' -Producto ',cantidad,': '); readln(inventario[cantidad].articulo); write(' -Precio: '); readln(inventario[cantidad].precio); write(' -Cantidad: '); readln(inventario[cantidad].cantidad); writeln; Write('¨Desea introducir otro producto? s/n: '); Readln(res); {si no, saco del ciclo} if (res='n') OR (res='N') then break; end;{Fin de introducir productor ciclo} end;{Fin de opcion 2} 2:{Reporte de productos} begin ClrScr; titulo('Reporte de productos'); writeln; writeln; for c:=1 to cantidad do begin writeln('Producto',c,': ',inventario[c].articulo); writeln(' Precio: $',inventario[c].precio:0:2); writeln(' Cantidad: ',inventario[c].cantidad); writeln; end;{ciclo de impresion} ReadKey; end;{fin de opcion 2 reporte de productos} end;{case} until opc=3; end. |
1.- Agregar
2.- Reporte
3.- Salir
Opcion: 1_
Producto 1: Papel(100 hojas)
Precio: $ 50
Cantidad: 50
Deseas agregar otro producto s/n: s_
Producto 2: Lapiz(HB)
Precio: $ 2.5
Cantidad: 300
Deseas agregar otro producto s/n: n
1.- Agregar
2.- Reporte
3.- Salir
Opcion: 2_
Papel(100 hojas), Precio $50, Cantidad 50.
Lapiz(HB), Precio $2.5, Cantidad 300.