[ Foro de Pascal ]

Total que se sume y me lea día, mes, año, número de factura

20-Oct-2021 15:46
Invitado (Karla)
0 Respuestas

Necesito ayuda urgente

El siguiente código es para crear una factura pero necesito realizar lo siguiente:
1. que me mande a llamar los siguientes datos y los muestre en la ejecución: día, mes, año, número de factura.
2. que el total de la cantidad y el precio de unidad del producto se escriba solo y no tener que colocar el resultado manualmente.

Les dejo el código por si alguien encuentra la solución.  Gracias

Program Factura;
uses crt;
type
 prodPrecs = record
   Producto: string;
Precio: integer;
  end;

var
 prodPrec: array[1..10] of prodPrecs;
 mas: char;
 acum, acum2, k, total, pagoRecibido, cambio: integer;
 
procedure dibujaCeldas(xi:integer; y:integer; xf:integer);
var
 i:integer;
Begin
  (* Linea horizontal arriba *)
  gotoxy(xi+1,y);
  for i:= xi to xf-2 do
    write(char(45));
  (* Linea horizontal arriba *)
  gotoxy(xi,y+2);
  for i:= xi+1 to xf do
    write(char(45));

  (* Linea vertical izquierda *)
   for i:= y to y+2 do
    begin
      gotoxy(xi,i);
  write(char(124));
    end;
   for i:= y to y+2 do
    begin
  (* Linea vertical derecha *)
      gotoxy(xf,i);
  write(char(124));
    end;
   for i:= y to y+2 do
    begin
      gotoxy(60,i);
  write(char(124));
    end;
End;

BEGIN
 ClrScr;
 acum:= 1;
 write('Ingrese Dia: '); readln(mas);
 write('Ingrese Mes: '); readln(mas);
 write('Ingrese Año: '); readln(mas);
 write('Factura No. : '); readln(mas);
 write('Desea introducir algun producto?: '); readln(mas);

 while mas='s' do
  Begin
    ClrScr;

    write('Cantidad a comprar: '); readln(prodPrec[acum].Producto);
    write('Nombre del Producto: '); readln(prodPrec[acum].Producto);
write('Precio de Unidad del producto: '); readln(prodPrec[acum].Precio);
    write('Total: '); readln(prodPrec[acum].Precio);
write('¿Desea agregar otro producto?: '); readln(mas);
acum:= acum + 1;
if acum>5 then
 Begin
   writeln('El maximo de productos permitidos es de 5.'); readln;
mas:= 'n';
 End;
  End;
 if acum>1 then

  Begin
    ClrScr;
    gotoxy(34,2); writeln('F A C T U R A');
    gotoxy(8,4); writeln('DIA ');
    gotoxy(12,4); write('MES ');
    gotoxy(16,4); write('ANO ');
    gotoxy(55,4); write('FACTURA DE VENTA No. ');

total:= 0;
    acum2:= 5;

    For k:=1 to acum - 1 do
 Begin
   acum2:= acum2 + 3;
dibujaCeldas(3,acum2,77);
gotoxy(5,acum2 + 1); writeln(prodPrec[k].Producto);
gotoxy(65,acum2 + 1); writeln(prodPrec[k].Precio);
       total:= total + prodPrec[k].Precio;
 End;
acum2:= acum2 + 2;
dibujaCeldas(10,acum2,77);

    gotoxy(45,acum2 + 1); writeln('T O T A L');
gotoxy(65,acum2 + 1); writeln(total);

gotoxy(30,20); write('Cuanto va a pagar?: '); readln(PagoRecibido);
cambio:= PagoRecibido - total;
gotoxy(30,21); writeln('Su vuelto es: ', cambio);
  End;  

readln;
end.




(No se puede continuar esta discusión porque tiene más de dos meses de antigüedad. Si tienes dudas parecidas, abre un nuevo hilo.)