You are on page 1of 20

UNIVERSIDAD MAYOR DE SAN SIMON

COMPUTACION PARA INGENIERIA

PROGRAMA 1
CARACTERISTICAS PERSONALES
program caracteristicas_personales;
uses
forms, dialogs,sysutils;
begin
showmessage('hola mi nombre es juan'+#13+'me gusta jugar futbol');
showmessage('vivo en cercado'+#13+'estoy en ing civil');
showmessage('soy signo piscis'+#13+'peso 78 kg');
end.

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA

PROGRAMA 2
DISTANCIA ENTRE 2 PUNTOS EN COORDENADAS
CILINDRICAS
Program Distancia_en_coordenadas_Cilindricas;
Uses
Forms,Dialogs,Sysutils;
var
r1,a1,h1,r2,a2,h2,x1,y1,z1,x2,y2,z2,distancia:double;
begin
r1:=strtofloat(inputbox('punto1','ingrese radial 1',''));
a1:=strtofloat(inputbox('punto1','ingrese azimutal 1',''));
h1:=strtofloat(inputbox('punto1','ingrese horitzontal 1',''));
r2:=strtofloat(inputbox('punto2','ingrese radial 2',''));
a2:=strtofloat(inputbox('punto2','ingrese azimutal 2',''));
h2:=strtofloat(inputbox('punto2','ingrese horitzontal 2',''));
x1:=r1*cos(a1/180);
y1:=r1*sin(a1/180);
z1:=h1;
x2:=r2*cos(a2/180);
y2:=r2*sin(a2/180);
z2:=h2;
distancia:=sqrt(sqr(x2-x1)+sqr(y2-y1)+sqr(z2-z1));
showmessage('la distancia entre 2 puntos en coordenadas cilindricas es: ' +floattostr(distancia));
end.

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA

PROGRAMA 3
PROMEDIO DE 8 ESTUDIANTES CON 10 NOTAS
program Promedio_de_notas;
uses
forms,
dialogs,
sysutils;
var
n:string;
n1,n2,n3,n4,n5,n6,n7,n8,n9,n10:integer;
type testudiante=class
procedure iniciar(n:string;n1,n2,n3,n4,n5,n6,n7,n8,n9,n10:integer);
function media:real;
procedure mostrar;
private
nombre:string;
nota1,nota2,nota3,nota4,nota5,nota6,nota7,nota8,nota9,nota10:REAL;
end;
procedure testudiante.iniciar;
begin
nombre:=n;nota1:=n1;nota2:=n2;nota3:=n3;nota4:=n4;nota5:=n5;nota6:=n6;nota7:=n7;nota8:=n8
;nota9:=n9;nota10:=n10;
end;
function testudiante.media;
begin
media:=(nota1+nota2+nota3+nota4+nota5+nota6+nota7+nota8+nota9+nota10)/10;
end;
procedure testudiante.mostrar;
begin
showmessage(nombre+#13+#13+#13'Ha Obtenido de PROMEDIO'+#13'='+floattostr(media));
end;
var e1,e2,e3,e4,e5,e6,e7,e8:testudiante;
begin
e1:=testudiante.Create;
e2:=testudiante.Create;
e3:=testudiante.Create;
e4:=testudiante.Create;
e5:=testudiante.Create;
e6:=testudiante.Create;
e7:=testudiante.Create;
e8:=testudiante.Create;
e1.iniciar('Gilmar Alvis',100,100,100,100,100,100,100,100,100,100);e1.mostrar;
e2.iniciar('Edson Zabala',40,80,77,54,80,50,80,50,50,70);e2.mostrar;
e3.iniciar('Omar Dominguez',70,60,50,60,80,65,100,80,80,75);e3.mostrar;
e4.iniciar('Cristian Martinez',58,50,90,60,40,20,46,50,60,80);e4.mostrar;

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA
e5.iniciar('Isaac Garcia',70,70,80,70,70,90,80,60,87,100);e5.mostrar;
e6.iniciar('Guido Cruz',100,90,10,100,80,80,50,85,40,60);e6.mostrar;
e7.iniciar('Marlene Estrada',80,100,40,80,87,80,90,100,50,60);e7.mostrar;
e8.iniciar('Carlos Tamez',100,70,60,65,80,50,80,68,70,80);e8.mostrar;
end.

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA

PROGRAMA 4
MAYOR DE 8 NUMEROS
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Button2: TButton;
Edit9: TEdit;
Label10: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
a,b,c,d,e,f,g,h,mayor:double;
begin
try
a:=strtofloat(edit1.text);
b:=strtofloat(edit2.text);
c:=strtofloat(edit3.text);
d:=strtofloat(edit4.text);
e:=strtofloat(edit5.text);
f:=strtofloat(edit6.text);
g:=strtofloat(edit7.text);
h:=strtofloat(edit8.text);
mayor:=a;
if(b>mayor)then
mayor:=b;
if(c>mayor)then
mayor:=c;
if(d>mayor)then
mayor:=d;
if(e>mayor)then
mayor:=e;
if(f>mayor)then
mayor:=f;
if(g>mayor)then
mayor:=g;
if(h>mayor)then
mayor:=h;
edit9.Text:=floattostr(mayor);
button1.Enabled:=false;
except
on econverterror do
begin
showmessage('Existe Algun Error');
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close
end;
end.

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA

PROGRAMA 5
3 USUARIOS Y 4 CONTRASEAS CON 60 SEGUNDOS Y 3
INTENTOS
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Buttons;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label12: TLabel;
Timer1: TTimer;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
procedure BitBtn1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if((LowerCase(Edit1.Text)='pedro')and(LowerCase(Edit4.Text)='1'))then
begin
if((LowerCase(Edit2.Text)='juan')and(LowerCase(Edit5.Text)='2'))then
begin
if((LowerCase(Edit3.Text)='lucas')and(LowerCase(Edit6.Text)='3'))then
begin
if(LowerCase(Edit7.Text)='4')then
begin
Timer1.Enabled:=false;
MessageDlg('BIENVENIDO LOGRO ENTRAR AL SISTEMA',mtinformation,[mbOK],1);
close
end
end
end
end

else
if Form1.Tag<3 then
showmessage('CONTRASEA INCORRECTA INTENTE DE NUEVO');
if Form1.Tag>=3 then
begin
Timer1.Enabled:=false;
Label12.Caption:='';
MessageDlg('SE LE TERMINO LAS OPORTUNIDADES', mtwarning,[MbOK],1);
close
end
else
Form1.Tag:=Form1.Tag+1;
edit1.SelStart:=0;
edit1.SelLength:=length(edit1.text);
edit1.SetFocus;
end;

procedure TForm1.Timer1Timer(Sender: TObject);


begin
Label12.Caption:='LE RESTAN: '+IntToStr (Timer1.Tag)+' SEGUNDOS';
Timer1.Tag:=Timer1.Tag-1;
if Timer1.Tag=0 then

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA
begin
Timer1.Enabled:=false;
Label12.Caption:='';
ShowMessage('SU TIEMPO ACABO INTENTE DESPUES');
close
end;
end;
end.

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA

PROGRAMA 6
CONVERSION DE UNIDADES
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Button1: TButton;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure Edit3KeyPress(Sender: TObject; var Key: Char);
procedure Edit4KeyPress(Sender: TObject; var Key: Char);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var
kgcm2,libpul2,kippie2,tonm2:double;
begin
case ord(key) of
13:begin

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA
if(sender=edit1)then
kgcm2:=strtofloat(edit1.text);
libpul2:=kgcm2*(22050/1550);
kippie2:=kgcm2*2.0286;
tonm2:=kgcm2*10;
edit2.Text:=floattostr(libpul2);
edit3.text:=floattostr(kippie2);
edit4.text:=floattostr(tonm2);
end;
end;
end;
procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
var
kgcm2,libpul2,kippie2,tonm2:double;
begin
case ord(key) of
13:begin
if(sender=edit2)then
libpul2:=strtofloat(edit2.text);
kgcm2:=libpul2*(31/441);
kippie2:=libpul2*0.1426;
tonm2:=libpul2*(310/441);
edit1.Text:=floattostr(kgcm2);
edit3.text:=floattostr(kippie2);
edit4.text:=floattostr(tonm2);
end;
end;
end;
procedure TForm1.Edit3KeyPress(Sender: TObject; var Key: Char);
var
kgcm2,libpul2,kippie2,tonm2:double;
begin
case ord(key) of
13:begin
if(sender=edit3)then
kippie2:=strtofloat(edit3.text);
kgcm2:=kippie2*(5000/10143);
libpul2:=kippie2*(1000/142.6);
tonm2:=kippie2*(1/0.20286);
edit1.Text:=floattostr(kgcm2);
edit2.text:=floattostr(libpul2);
edit4.text:=floattostr(tonm2);
end;
end;
end;
procedure TForm1.Edit4KeyPress(Sender: TObject; var Key: Char);
var

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA
kgcm2,libpul2,kippie2,tonm2:double;
begin
case ord(key) of
13:begin
if(sender=edit4)then
tonm2:=strtofloat(edit4.text);
kgcm2:=tonm2*(1/10);
libpul2:=tonm2*(2205/1550);
kippie2:=tonm2*0.20286;
edit1.Text:=floattostr(kgcm2);
edit2.text:=floattostr(libpul2);
edit3.text:=floattostr(kippie2);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
close
end;
end.

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA

PROGRAMA 7
TANGENTE APROXIMADA
unit unit1;
interface
uses
windows, messages, sysutils, variants, classes, graphics, controls, forms,
dialogs, stdctrls;
type
tform1 = class(tform)
button1: tbutton;
edit1: tedit;
edit2: tedit;
edit3: tedit;
label1: tlabel;
label2: tlabel;
label3: tlabel;
label4: tlabel;
button2: tbutton;
procedure button1click(sender: tobject);
procedure button2click(sender: tobject);
private
{ private declarations }
public
{ public declarations }
end;
var
form1: tform1;
implementation
{$r *.dfm}
function coseno(ang:double):real;
var t,x,s,i:double;
begin
x:=(ang*3.141592654)/180;
t:=-(x*x)/2;

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA
s:=1+t;
i:=1;
while(abs(t/s)>= 1e-500)do
begin
i:=i+1;
t:=((-t)*(x*x))/(2*i*(2*i-1));
s:=s+t;
end;
coseno:=s;
end;
function seno(ang:double):real;
var
s,x,xrad,term:double;
k:integer;
begin
xrad:=(ang*3.141592654)/180;
s:=0;
term:=xrad;
k:=1;
repeat
s:=s+term;
term:=(-1)*term*(xrad*xrad)/((k+2)*(k+1));
k:=k+1;
until (abs(term)<1e-500);
seno:=s;
end;
procedure tform1.button1click(sender: tobject);
var
xsex,xrad,res:double;
begin
xsex:=strtofloat(edit1.text);
xrad:=(xsex*3.141592654)/180;
res:=(seno(xsex))/(coseno(xsex));
edit2.text:=floattostr(xrad);
edit3.text:=floattostr(res);
end;
procedure tform1.button2click(sender: tobject);
begin
close
end;
end.

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA

PROGRAMA 8
RAIZ APROXIMADA DE 11
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
GroupBox1: TGroupBox;
Label2: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
const cota=1E-6;
var
Form1: TForm1;
implementation
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);


begin
CLOSE
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var
ant,dif,x,r:real;
begin
if(key=#13)then

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA
begin
x:=strtofloat(edit1.text);
r:=x/11;
repeat
ant:=r;
r:=(10*ant+x/(ant*ant*ant*ant*ant*ant*ant*ant*ant*ant))/11;
dif:=abs(x-(r*r*r*r*r*r*r*r*r*r*r));
until (dif<1E-6);
label2.caption:='r= '+floattostr(r);
end;
end;
end.

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA

PROGRAMA 9
GRAFICAR NOMBRE Y APELLIDO
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormPaint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormPaint(Sender: TObject);
begin
with canvas do
begin
pen.color:=clblue;
pen.Width:=3;
polyline([point(40,40),point(80,40),point(60,40),point(60,80),point(40,80),point(40,60)]); //dibuja
la letra J
polyline([point(100,40),point(100,80),point(120,80),point(120,40)]); //dibuja la letra U
polyline([point(140,80),point(140,40),point(160,40),point(160,60),point(140,60),point(160,60),poi
nt(160,80)]); //dibuja la letra A
polyline([point(180,80),point(180,40),point(200,80),point(200,40)]);//dibuja la letra N
polyline([point(280,40),point(260,40),point(260,80),point(280,80)]);//dibuja la letra C
polyline([point(300,80),point(300,40),point(320,40),point(320,60),point(300,60),point(320,80)]);//
dibuja la letra R
end;

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA
end;
end.

PROGRAMA 10
GRAFICAR CUADRADOS Y RECTANGULOS DINAMICOS
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x,y,dx,dy:integer;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);

Aux. Joseph Bill Salvatierra Barrionuevo

UNIVERSIDAD MAYOR DE SAN SIMON


COMPUTACION PARA INGENIERIA
begin
x:=random(screen.Width-10);
y:=random(screen.Height-10);
canvas.pen.color:=random(65535);
canvas.Pen.width:=random(7);
dx:=random(400);
dy:=random(400);
canvas.rectangle(x,y,x+dx,y+dx ); //grafica cuadrados
canvas.rectangle(y,x,y+dy,x+dx); //grafica rectangulos
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
windowstate:=wsmaximized;
timer1.interval:=50;
randomize;
end;
end.

Aux. Joseph Bill Salvatierra Barrionuevo

You might also like