esercizi con elaborazione dati con turbo pascal 1.1 su mac

 

 

PROGRAM ANA1;
{ esempio raccolta dati con RECORD }
type allievi=record
        nome:string;
        indirizzo:string;
        regione:string;
        credito:integer;
        debito:integer;
        saldo:integer;
             end;
             
 var studente:allievi;
     a,studenti:integer;
procedure richiesta;
begin
 writeln('indica numero studenti=');
 readln(studenti);
end;
procedure pausa;
begin
 writeln('premi return');
 readln;
 clearscreen;
end;
 
procedure scrividati;      
 begin 
   writeln('scrivi nome,indirizzo,regione,credito,debito');
   writeln('dopo ogni dato premi return');
   writeln;
   for a:=1 to studenti do
    begin
     writeln('studente n.',a);
     writeln;
     WRITE('nome.............');readln(studente.nome);
     WRITE('indirizzo........');readln(studente.indirizzo);
     WRITE('regione..........');readln(studente.regione);
     WRITE('credito...........');readln(studente.credito);
     WRITE('debito............');readln(studente.debito);  
     studente.saldo:=studente.credito-studente.debito;
     writeln('-----------------------');
    end;
    end;
    
 procedure TOTALE;
 begin   
    for a:=1 to studenti do
     begin
      WRITE('nome..............');writeln(studente.nome);
      WRITE('indirizzo.........');writeln(studente.indirizzo);
      WRITE('regione...........');writeln(studente.regione);
      WRITE('credito............');writeln(studente.credito);
      WRITE('debito.............');writeln(studente.debito);
      WRITE('saldo...............');writeln(studente.saldo);
      writeln('----------------');
     end;
   end;                 
   
   procedure parziale;
 begin   
    for a:=1 to studenti do
     begin
      writeln('nome.........',studente.nome);
      writeln('indirizzo....',studente.indirizzo);
      writeln('credito.......',studente.credito);
      writeln('----------------');
     end;
   end;                 
   begin
    clearscreen;
    richiesta;
    scrividati;
    pausa;
    totale;
    pausa;
    parziale;
    pausa;
   end. 

 


procedure clienti;
  begin
   nome[1]:='Rossi';credito[1]:=6000;debito[1]:=100;
   nome[2]:='Rossini';credito[2]:=2000;debito[2]:=200;
   nome[3]:='Verdi';credito[3]:=3000;debito[3]:=300;
   nome[4]:='Bassi';credito[4]:=4000;debito[4]:=400;
   nome[5]:='Grasso';credito[5]:=5000;debito[5]:=500;
   nome[6]:='Rosati';credito[6]:=1000;debito[6]:=100;
   nome[7]:='Bianchi';credito[7]:=1000;debito[7]:=100;
   nome[8]:='Pascoli';credito[8]:=1000;debito[8]:=100;
  end;  

 


program dati;
{ uso di set  }
var setx:array[1..6] of integer;
    a:integer;
    
begin
  clearscreen;
  setx[1]:=10; setx[2]:=20; setx[3]:=30;
  setx[4]:=40; setx[5]:=50; setx[6]:=60;
 for a:=1 to 6 do
  writeln(a,'...',setx[a]);
  
  readln;
  end.
  

program rubrica;
{ eempio gestione database semplice }
var nome:array[1..5] of string[15];
       credito:array[1..5] of integer;
       debito:array[1..5] of integer;
       saldo:array[1..5] of integer;
       a,ctotale,dtotale,stotale:integer;
       
procedure clienti;
  begin
   nome[1]:='Rossi';nome[2]:='Bianchi';nome[3]:='Verdi';
   nome[4]:='Rossini';nome[5]:='Bianchini';       
  end;
  
 procedure crediti;
  begin
   credito[1]:=1000;credito[2]:=2000;credito[3]:=3000;
   credito[4]:=4000;credito[5]:=5000;       
  end;
  
  procedure debiti;
  begin
   debito[1]:=100;debito[2]:=200;debito[3]:=300;
   debito[4]:=400;debito[5]:=500;       
  end;
     
  BEGIN
   ctotale:=0;dtotale:=0;stotale:=0;
   for a:=1 to 5 do
    begin
     clienti;crediti;debiti;
     ctotale:=ctotale+credito[a];
     dtotale:=dtotale+debito[a];
    end;   
    writeln('nomi':20,'credito':10,'debito':10,'saldo':10);
    writeln('----------------------------------------------------');
    for a:=1 to 5 do
     begin
      saldo[a]:=credito[a]-debito[a];
      stotale:=stotale+saldo[a];
      writeln(nome[a]:20,credito[a]:10,debito[a]:10,saldo[a]:10); 
      writeln;
      end;
      writeln('---------------------------------------------------');
      writeln('relazione finale':40);
      writeln('totali':20,'credito':10,'debito':10,'saldo':10);
      writeln(ctotale:30,dtotale:10,stotale:10);     
     writeln('premi return');
     readln;
 end.     

program rubrica1;
{ eempio gestione database semplice  e gestione FONT}
uses memtypes,quickdraw;
var nome:array[1..5] of string[15];
       credito:array[1..5] of integer;
       debito:array[1..5] of integer;
       saldo:array[1..5] of integer;
       a,ctotale,dtotale,stotale:integer;
       
procedure clienti;
  begin
   nome[1]:='Rossi';nome[2]:='Bianchi';nome[3]:='Verdi';
   nome[4]:='Rossini';nome[5]:='Bianchini';       
  end;
  
 procedure crediti;
  begin
   credito[1]:=1000;credito[2]:=2000;credito[3]:=3000;
   credito[4]:=4000;credito[5]:=5000;       
  end;
  
  procedure debiti;
  begin
   debito[1]:=100;debito[2]:=200;debito[3]:=300;
   debito[4]:=400;debito[5]:=500;       
  end;
     
  BEGIN
   ctotale:=0;dtotale:=0;stotale:=0;
   for a:=1 to 5 do
    begin
     clienti;crediti;debiti;
     ctotale:=ctotale+credito[a];
     dtotale:=dtotale+debito[a];
    end;  
    textfont(0);
    textsize(12);
    textface([italic]); 
    writeln('nomi':20,'credito':15,'debito':15,'saldo':15);
    writeln('----------------------------------------------------');
    for a:=1 to 5 do
     begin
      saldo[a]:=credito[a]-debito[a];
      stotale:=stotale+saldo[a];
      writeln(nome[a]:20,credito[a]:15,debito[a]:15,saldo[a]:15); 
      writeln;
      end;
      writeln('---------------------------------------------------');
      textfont(4);
      textface([shadow]);
      writeln('relazione finale':30);
      writeln;
      textface([]);
      textfont(0);      
      writeln('totali':20,'credito':15,'debito':15,'saldo':15);
      writeln;
      writeln('          ':20,ctotale:15,dtotale:15,stotale:15);    
      textfont(4);
      textface([shadow]);
      textsize(18); 
      writeln;
     writeln('premi return');
     readln;
 end.     

program rubrica3;
{ eempio gestione database semplice  e gestione FONT}
uses memtypes,quickdraw;
const k=8;
{ variare valore di K per diverso numero record:aggiungere in CLIENTI}
var nome:array[1..k] of string;
       credito:array[1..k] of integer;
       debito:array[1..k] of integer;
       saldo:array[1..k] of integer;
       a,ctotale,dtotale,stotale:integer;
       
procedure clienti;
  begin
   nome[1]:='Rossi';credito[1]:=1000;debito[1]:=100;
   nome[2]:='Rossini';credito[2]:=2000;debito[2]:=200;
   nome[3]:='Verdi';credito[3]:=3000;debito[3]:=300;
   nome[4]:='Bassi';credito[4]:=4000;debito[4]:=400;
   nome[5]:='Grasso';credito[5]:=5000;debito[5]:=500;
   nome[6]:='Rosati';credito[6]:=1000;debito[6]:=100;
   nome[7]:='Bianchi';credito[7]:=1000;debito[7]:=100;
   nome[8]:='Pascoli';credito[8]:=1000;debito[8]:=100;
  end;  
       
  BEGIN
   ctotale:=0;dtotale:=0;stotale:=0;
   for a:=1 to k do
    begin
     clienti;
     ctotale:=ctotale+credito[a];
     dtotale:=dtotale+debito[a];
    end;  
    textfont(0);
    textsize(12);
    textface([italic]); 
    writeln('nomi':20,'credito':15,'debito':15,'saldo':15);
    writeln('----------------------------------------------------');
    for a:=1 to k do
     begin
      saldo[a]:=credito[a]-debito[a];
      stotale:=stotale+saldo[a];
      writeln(nome[a]:20,credito[a]:15,debito[a]:15,saldo[a]:15); 
      end;
      writeln('---------------------------------------------------');
      textfont(4);
      textface([shadow]);
      writeln('relazione finale':30);
      writeln;
      textface([]);
      textfont(0);      
      writeln('totali':20,'credito':15,'debito':15,'saldo':15);
      writeln;
      writeln('          ':20,ctotale:15,dtotale:15,stotale:15);    
      textfont(4);
      textface([shadow]);
      textsize(18); 
      writeln;
     writeln('premi return');
     readln;
 end.     

program rubrica4;
{ esempio gestione database semplice  e gestione FONT}
{INSERIMENTO CONDIZIONE RICERCA con IF }
uses memtypes,quickdraw;
const k=8;
{ variare valore di K per diverso numero record:aggiungere in CLIENTI}
var nome:array[1..k] of string;
       credito:array[1..k] of integer;
       debito:array[1..k] of integer;
       saldo:array[1..k] of integer;
       a,ctotale,dtotale,stotale:integer;
       
procedure clienti;
  begin
   nome[1]:='Rossi';credito[1]:=6000;debito[1]:=100;
   nome[2]:='Rossini';credito[2]:=2000;debito[2]:=200;
   nome[3]:='Verdi';credito[3]:=3000;debito[3]:=300;
   nome[4]:='Bassi';credito[4]:=4000;debito[4]:=400;
   nome[5]:='Grasso';credito[5]:=5000;debito[5]:=500;
   nome[6]:='Rosati';credito[6]:=1000;debito[6]:=100;
   nome[7]:='Bianchi';credito[7]:=1000;debito[7]:=100;
   nome[8]:='Pascoli';credito[8]:=1000;debito[8]:=100;
  end;  
       
  BEGIN
   ctotale:=0;dtotale:=0;stotale:=0;
   for a:=1 to k do
    begin
     clienti;
     ctotale:=ctotale+credito[a];
     dtotale:=dtotale+debito[a];
    end;  
    textfont(0);
    textsize(12);
    textface([italic]); 
    writeln('nomi':20,'credito':15,'debito':15,'saldo':15);
    writeln('----------------------------------------------------');
    for a:=1 to k do
     begin
      saldo[a]:=credito[a]-debito[a];
      stotale:=stotale+saldo[a];
      { inserimento condizione ricerca }
      if (credito[a]>=3000) or (nome[a]= 'Pascoli' )then
      writeln(nome[a]:20,credito[a]:15,debito[a]:15,saldo[a]:15); 
      end;
      writeln('---------------------------------------------------');
      textfont(4);
      textface([shadow]);
      writeln('relazione finale':30);
      writeln;
      textface([]);
      textfont(0);      
      writeln('totali':20,'credito':15,'debito':15,'saldo':15);
      writeln;
      writeln('          ':20,ctotale:15,dtotale:15,stotale:15);    
      textfont(4);
      textface([shadow]);
      textsize(18); 
      writeln;
     writeln('premi return');
     readln;
 end.     

program rubrica5;
{ esempio gestione database semplice  e gestione FONT}
{INSERIMENTO CONDIZIONE RICERCA con IF }
{ richiama archivio dati da disco con $I clienti }
{ la procedura clienti e' stata registrata a parte con SAVE AS }
uses memtypes,quickdraw;
const k=8;
{ variare valore di K per diverso numero record:aggiungere in CLIENTI}
var nome:array[1..k] of string;
       credito:array[1..k] of integer;
       debito:array[1..k] of integer;
       saldo:array[1..k] of integer;
       a,ctotale,dtotale,stotale:integer;
       
 {$I clienti}      
      
  BEGIN
   ctotale:=0;dtotale:=0;stotale:=0;
   for a:=1 to k do
    begin
     clienti;
     ctotale:=ctotale+credito[a];
     dtotale:=dtotale+debito[a];
    end;  
    textfont(0);
    textsize(12);
    textface([italic]); 
    writeln('nomi':20,'credito':15,'debito':15,'saldo':15);
    writeln('----------------------------------------------------');
    for a:=1 to k do
     begin
      saldo[a]:=credito[a]-debito[a];
      stotale:=stotale+saldo[a];
      { inserimento condizione ricerca }
      if (credito[a]>=3000) or (nome[a]= 'Pascoli' )then
      writeln(nome[a]:20,credito[a]:15,debito[a]:15,saldo[a]:15); 
      end;
      writeln('---------------------------------------------------');
      textfont(4);
      textface([shadow]);
      writeln('relazione finale':30);
      writeln;
      textface([]);
      textfont(0);      
      writeln('totali':20,'credito':15,'debito':15,'saldo':15);
      writeln;
      writeln('          ':20,ctotale:15,dtotale:15,stotale:15);    
      textfont(4);
      textface([shadow]);
      textsize(18); 
      writeln;
     writeln('premi return');
     readln;
 end.