Vous êtes sur la page 1sur 43

Universidad Nacional Mayor de San Marcos

Facultad de Ciencias Físicas


Escuela Profesional Ingeniería Mecánica de
Fluidos

PROBLEMAS SENCILLOS
RESUELTOS CON FORTRAN

Ing. William Chauca N.


Actividad
1.-
program rectangulo
real::b,h
real::a,p
print*,”Ingresar b y h”
read*,b,h
a=b*h
p=(b+h)*2
print*,”Resultados”
print*,”Area= ”,a
print*,”Perimetro= ”,p
end program rectangulo

2.-
program cilindro
real::r,h
real,parameter::pi=3.14159
real::al,at,ab
print*,”Ingresar r,h”
read*,r,h
ab=pi*(r**2)
al=2*pi*r*h
at=(2*ab)+al
print*,”Resultados”
print*,”Area de la base= ”,ab
print*,”Area lateral= ”,al
print*,”Area total = “,at
end program cilindro

3.-
program institucion social
real::d
real::cs,cn,es,as
print*.”Ingresar donacion”
read*,d
cs=0.25*d
cn=0.35*d
es=0.25*d
as=0.15*d
print*,”Reparto de la donacion”
print*,”Monto para el centro de salud= ”,cs
print*,”Monto para el comedor de niños= ”,cn
print*,”Monto para la escuela= ”,es
print*,”Monto para el asilo= ”,as
end program institucion social

4
program convertidor
real::m
real::p,y
print*,”Ingresar longitud a convertir”
read*,m
p=0.3048*m
y=3*p
print*,”Longitud convertida”
print*,”pies= ”,p
print*,”yardas= ”,y
end program convertidor

5
program monto total en euros
real::ds,dd,dm
real::de
print*,”Ingresar soles”
read*,ds
print*,”Ingresar dolares”
read*,dd
print*,”Ingresar marcos”
read*,dm
de=((ds/3.51)*1.09)+(dd*1.09)+((dm/2.12)*1.09)
print*,”Monto total en euros= ”,de
end program monto total en euros

6
program segundos
real::ts
real::h,m,s,resto
print*,”Ingresar total de segundos”
read*,ts
h=ts/3600
resto=ts%3600
m=resto/60
s=resto%60
print*,”Imprimir HH:MM:SS”
print*h,m,s
end program segundos

7
program sumayproducto
real:: n1,n2,n3,n4
real::s,p
print*,”Ingresar numero”
print*,”Ingresar primera cifra”
read*,n1
print*,”Ingresar segunda cifra”
read*,n2
print*,”Ingresar tercera cifra”
read*,n3
print*,”Ingresar cuarta cifra”
read*,n4
s=n1+n2+n3+n4
p=n1*n2*n3*n4
print*,”Resultados”
print*,”Suma = ”,s
print*,”Producto= ”,p
end program sumayproducto

8
program oferta
real::p,n
real::mc,md,mp
print*,”Ingresar precio de productos”
read*,p
print*,”Ingresar cantidad de productos”
read*,n
mc=p*n
md=0.11*mc
mp=mc-md
print*,”Monto de la compra= ”,mc
print*,”Descuento= ”,md
print*,”Monto a pagar= ”,mp
end program oferta

Autoevaluacion
1
program grados
real::S
real::C,R
real,parameter::pi=3.14159
print*,”Ingresar grados sexagesimales”
read*,S
C=(S*10)/9
R=(S*pi)/180
print*,”Imprimir grados convertidos”
print*,”En centesimales= ”,C
print*,”En radianes= ”,R
end program grados

2
program temperatura
real::C
real::F,R,K
print*,”Ingrese grados centigrados”
read*,C
F=(9*C)/5+32
R=C+460
K=R-187
print*,”Grados convertidos”
print*,”En Fahrenheit= “,F
print*,”En Rankine= ”,R
print*,”En Kelvin= ”,K
end program temperatura

3
program pulgada
real::pulg
real::p,y,cm,m
print*,”Ingrese longitud en pulgadas”
read*,pulg
p=pulg/12
y=p/3
cm=pulg*2.54
m=cm/100
print*,”Imprimir conversiones”
print*,”A pies= ”,p
print*,”A yardas= ”,y
print*,”A centimetros= ”,cm
print*,”A metros= ”,m
end program pulgada

4
program gigabytes
real::Gb
real::Mb,Kb,B
print*,”Ingresar Gigabytes”
read*,Gb
Mb=1024*Gb
Kb=1024*Mb
B=1024*Kb
print*,”Resultados”
print*,”A Megabytes= ”,Mb
print*,”A Kilobytes= ”,Kb
print*,”A Bytes= ”,B
end program gigabytes

5
program soles
real::S
real::E,M,D
print*,”Ingrese cantidad en soles”
read*,S
D=s/3.51
E=D*1.09
M=D*2.12
print*,”En dolares= ”,D
print*,”En euros= ”,E
print*,”En marcos= ”,M
end program soles
6
program galones
real::G
real::L,M,P
print*,”Cantidad en galones”
read*,G
L=G*3.79
M=L/1000
P=m/0.0283
print*,”En litros= ”,L
print*,”En metros cubicos= ”,M
print*,”En pies cubicos= ”,P
end program galones

7
program longitud
real::Km,P,M
real::metros
print*,”Distancia en Kilometros”
read*,Km
print*,”Distancia en Pies”
read*,P
print*,”Distancia en Millas”
read*,M
metros=(Km*1000)+(P/3.2808)+(M*1609)
print*,”Distancia en metros= ”,metros
end program longitud

8
program estatura
real::Pies,pulgadas
real::m
print*,”Ingresar medidas”
print*,”Medida en pies”
read*,Pies
print*,”Medida en pulgadas”
read*,pulgadas
m=(Pies*0.3048)+(pulgadas*0.0254)
print*,”Estatura en metros= ”,m
end program estatura

9
program gasolina
real::G,P
real:: Mc,Pc,Yc
print*,”Ingresar cantidades”
print*,”En galones”
read*,G
print*,”En pies cubicos”
read*,P
Mc=((3.79/1000)*G)+(P*0.0283)
Pc=Mc/0.0283
Yc=Pc/27
print*,”Resultados”
print*,”En metros cubicos= ”,Mc
print*,”En pies cubicos= ”,Pc
print*,”En yardas cubicas= ”,Yc
end program gasolina

10
program velocidad
real::tm,ts,cs,l
real::v
print*,”Ingrese tiempo en minutos”
read*,tm
print*,”Ingrese tiempo en segundos”
read*,ts
print*,”Ingrese tiempo en centesimas”
read*,cs
print*,”Ingrese longitud”
read*,l
v=(l/1000)/((tm/60)+(ts/3600)+(cs/360000))
print*,”Velocidad en km/h= ”,v
end program velocidad
12
program reparticion
real::g,a1,a2,a3
real::m1,m2,m3
print*,”Ingrese Ganancia”
read*,g
print*,”Ingrese numero de acciones de socio 1”
read*,a1
print*,”Ingrese numero de acciones de socio 2”
read*,a2
print*,”Ingrese numero de acciones de socio 3”
read*,a3
m1=g*(ac1/(ac1+ac2+ac3))
m2=g*(ac2/(ac1+ac2+ac3))
m3=g*(ac3/(ac1+ac2+ac3))
print*,”Monto para cada socio”
print*,”Monto para socio 1= ”,m1
print*,”Monto para socio 2= ”,m2
print*,”Monto para socio 3= ”,m3
end program reparticion

14
program donacion
real::d
real::p,m,g,t
print*,”Monto de la donacion”
read*,d
m=0.45*d
g=0.3*d
p=m+g
t=d-(m+g+p)
print*,”Monto Medicina General= ”,m
print*,”Monto Ginecologia= ”,g
print*,”Monto Pediatria= ”,p
print*,”Monto Traumatologia= ”,t
end program donacion

15
Program vendedor
real::mt
real::sb,c,d,sn
print*,”Monto total vendido”
read*,mt
c=0.09*mt
sb=300+c
d=0.11*sb
sn=sb-d
print*,”Comision= ”,c
print*,”Sueldo bruto= ”,sb
print*,”Descuento= ”,d
print*,”Sueldo neto= ”,sn
end program vendedor

17
Program sumadetiempos
read::h1,m1,s1,h2,m2,s2
real::h3,m3,s3,resto
print*,”Ingresar horas”
read*,h1,h2
print*,”Ingresar minutos”
read*,m1,m2
print*”Ingresar segundos”
read*,s1,s2
ts=(h1+h2)*3600+(m1+m2)*60+(s1+s2)
h3=ts/3600
resto=ts%3600
m3=resto/60
s3=resto%60
print*,”Imprimir nueva hora”
print*,”Horas= ”,h3
print*,”Minutos= ”,m3
print*,”Segundos= ”,s3
end program sumadetiempos

18
Program horasquequedan
real::h1,m1,s1
real::h2,m2,s2
print*,”Tiempo transcurrido”
read*,h1,m1,s1
sr=86400-((h1*3600)+(m1*60)+s1)
h2=sr/3600
resto=sr%3600
m2=resto*60
s2=resto%60
print*,”Tiempo faltante”
print*,”Horas= ”,h2
print*,”Minutos= ”,m2
print*,”Segundos= ”,s2
end program horasquequedan

20
Program numero
real::n1,n2,n3,n4,n5,n6,n7
real::n
print*,”Ingresar numero”
read*,n1,n2,n3,n4,n5,n6,n7
n=n7n2n3n4n5n6n1
print*,”Mostrar nuevo numero= ”,n
end program numero

22
program_numero
real::n1,n2,n3,n4
real::n
print*,”ingresar numero”
read*,n1,n2,n3,n4
n=n4n3n2n1
print*,”mostrar nuevo numero= ”,n
end program_numero
problemas propuestas
PROBLEMA 1

PROGRAM PAR_IMPAR
INTEGER::X
PRINT*,"DIGITE UN NUMERO"
READ*,X
IF(MOD(X,2)==0)THEN
PRINT*,"EL NUMERO ES PAR"
ELSE
PRINT*,"EL NUMERO ES IMPAR"
END IF
END PROGRAM PAR_IMPAR

Problema 2
PROGRAM PAR
INTEGER::N
IF (N<1000) THEN
ELSE
IF(N>1)THEN
ELSE
IF (MOD(I,2)==0) THEN
PRINT*, "N es par positivo "
ELSE
PRINT*,"n es impar positivo"
ENDIF
END IF
END IF
END PROGRAM PAR
PROBLEMA 3
PROGRAM SUELDO

REAL::SB,MTV
REAL::C,SBRU,DESC,SN
PRINT*,"INGRESE EL MONTO TOTAL VENDIDO"
READ*,MTV
!PROCESO DE CALCULO
SB=300
C=MTV*15/100
SBRU=SB+C

IF (SBRU>1800) THEN
DESC=SBRU*15/100
ELSE
DESC=SBRU*11/100
END IF

SN=SBRU-DESC

!SALIDA DE DATOS
PRINT*," EL SUELDO BRUTO DEL TRABAJADOR ES =",SBRU
PRINT*,"EL DESCUENTO ASCIENDE A =",DESC
PRINT*,"EL SUELDO NETO DEL VENDEDOR ES =",SN
END PROGRAM SUELDO
Actividad 4

Program casas
Real::IM,CC
Real::CI,R
Print*,"Ingrese costo de la casa"
Read*,CC
Print*,"Ingrese ingreso mensual"
Read*,IM
If (IM<1250) then
CI=0.15*CC
R=(CC-CI)/120
Else if (IM>=1250) then
CI=0.3*CC
R=(CC-CI)/75
End if
Print*,"Resultados"
Print*,"Cuota inicial= ",CI
Print*,"Cuota mensual= ",R
End program casas

Autoevaluación
Problema 1
Program
real::A,B,C,D
REAL::CP
PRINT*,"INGRESE HORA DE ENTRADA"
READ*,A,B
PRINT*,"INGRESE HORA DE SALIDA"
READ*,C,D
!CALCULOS
R=D-B
IF(R==0)THEN
CP=(C-A)*2.5
ELSE
CP=(C-A+1)*2.5
END IF
PRINT*,CP
END PROGRAM
Problema 2
Program sueldo
Real::mv
Print*,”Ingrese monto vendido”
Read*,mv
If (mv-5000>0)
Sx=25*int((mv-5000)/500)
St=(mv*0.1)+sx
Else
St=mv*0.1
End if
Print*,st
End program sueldo

PROBLEMA 3

PROGRAM POSITIVO_NEGATIVO
INTEGER::X
PRINT*,"INGRESE UN NUMERO DE TRES CIFRAS"
READ*,X
IF(X>=0)THEN
PRINT*,"eL NUMERO ES POSITIVO"
ELSE
PRINT*,"EL NUMERO ES NEGATIVO"
END IF
END PROGRAM POSITIVO_NEGATIVO

Problema 04

PROGRAM BONO
INTEGER::S,N,B
IF (N>1) THEN
B=S+0.125*S+40*N
PRINT*,"IMPRIMIR BONO",B
ELSE
IF (N<=1)THEN
B=S+0.125*S
PRINT*,"IMPRIMIR BONO",B
END IF
END IF

PROBLEMA 5
PROGRAM OFERTA
INTEGER:: N
REAL:: MTC,DESC
PRINT*,"INGRESE EL MONTO TOTAL DE COMPRA"
READ*,MTC
PRINT*,"ESCOJA UN NUMERO AL AZAR"
READ*,N
IF (N<74) THEN
DESC=MTC*15/100
ELSE
DESC=MTC*20/100
END IF
!SALIDA DE DATOS
PRINT*,"EL DESCUENTO ASCIENDE A LA SUMA DE =",DESC
END PROGRAM OFERTA

Problema 6.
Program desicion
Real::P,DA,IT,TD,TI
Print*,"Ingresar precio del auto y/o terreno"
Read*,P
Print*,"Ingresar devaluacion anual de auto"
Read*,DA
Print*,"Ingresar incremento anual del terreno"
Read*,IT
Print*,"DOS AÑOS DESPUES :V"
TD=2*DA
TI=2*IT
If (TD<(TI/2)) then
Print*,"Comprar auto"
Else if (TD>=(TI/2))then
Print*,"Comprar terreno"
End if
End program decisión

Problema 7
PROGRAM PAGINA7
real::M
REAL::P,D
PRINT*,"INGRESE M"
READ*,M
IF(M<500000)THEN
P=0.3*M
ELSE
P=0.2*M
END IF
D=M-P
PRINT*,"RESULTADOS"
PRINT*,"DINERO PROPIO=",D
PRINT*,"PRESTAMO",P
END PROGRAM PAGINA7

Problema 8
Program hora
Integer::h1,m1,s1
Print*,”Ingrese la hora, minuto y
segundo separados por un espacio”
Read*,h1,m1,s1
If (h1<=12 .and. h1>0)
Print*,”La hora es “,h1,”:”,m1,”:”,s1,” am”
Else
If (h1>12 .and. h1<25)
H2=h1-12
Print*,” La hora es “,h2,”:”,m1,”:”,s1,” pm”
Else
Print*,”Error”
End if
End if
End program hora

PROBLEMA 9
PROGRAM CALCULAR_SUELDO
INTEGER::H,P !HORAS TRABAJADAS,PAGO NORMAL
PRINT*,"INGRESE LA CANTIDAD DE HORAS TRABAJADAS"
READ*,H
PRINT*,"INGRESE EL PAGO NORMAL"
READ*,P
IF(H>48)THEN
A=P*15/100 !A=AUMENTO
SB=P+A
IF(SB>1700)THEN
D=SB*11/100 !D=DECUENTO
SN=SB-D !SN=SUELDO NETO
ELSE
SN=SB
END IF
ELSE
SN=P
END IF
PRINT*,"EL SUELDO BRUTO ES=",SB
PRINT*,"EL DESCUENTO ES=",D
PRINT*,"EL SUELDO NETO ES=",SN
END PROGRAM CALCULAR_SUELDO

Problema 10
PROGRAM CAPICUA
INTEGER::N1,N2,N3
IF (N1==N3)THEN
PRINT*,"ES CAPICUA"
ELSE
PRINT*,"NO ES CAPICUA"
END IF
END PROGRAM CAPICUA

Problemas propuestos
DECISIÓN MULTIPLE

PROBLEMA 1
PROGRAM CATEGORIA
REAL::P
PRINT*,"EL VALOR DEL PROMEDIO PONDERADO ES="
READ*,P

IF(P<0.OR.P>20) THEN
PRINT*,"VALOR DE PROMEDIO NO VALIDO"
ELSEIF (P<12) THEN
PRINT*,"PERTENECE A LA CATEGORIA D"
ELSEIF (P<14) THEN
PRINT*,"PERTENECE A LA CATEGORIA C"
ELSEIF (P<17)THEN
PRINT*,"PERTENECE A LA CATEGORIA B"
ELSEIF (P<20) THEN
PRINT*,"PERTENECE A LA CATEGORIA A"
END IF
END PROGRAM CATEGORIA

Problema 2
Program dados
Real::D1,D2,D3
character(len=50)::C
Print*,"Ingrese lanzamientos obtenidos"
Read*,D1,D2,D3
If (D1+D2+D3==18) then
C="Excelente"
Else if(D1+D2==12 .or. D1+D3==12 .or. D2+D3==12) then
C="Muybien"
Else if (D1==6 .or. D2==6 .or. D3==6) then
C="Regular"
Else if (D1<6 .or. D2<6 .or. D3<6) then
C="Pesimo"
End if
Print*,"Calificacion obtenida= ",C
End program dados

Problema 3
PROGRAM Prob3
real::TPS,HORAS
REAL::SB,DESC,SN
PRINT*,"INGRESE TPS Y HORAS"
READ*,TPS,HORAS
SELECT CASE(TPS)
CASE(A)
SB=HORAS*21
CASE(B)
SB=HORAS*19.5
CASE(C)
SB=HORAS*17
CASE(D)
SB=HORAS*15.5
CASE DEFAULT
NO ESTA DENTRO DE LA CATEGORIA
END SELECT
!CALCULOS
DESC=0.2*SB
SN=SB-DESC
PRINT*,SB
PRINT*,DESC
PRINT*,SN
END PROGRAM Prob3

Problema 4
Program Imc
Real::w,h
Print*,”Ingrese el peso y la estatura”
Read*,w,h
Imc=w/(h**2)
If (imc<20)
Print*,”Delgado”
Else
If (20<=imc .and. imc<25)
Print*,”Normal”
Else
If (25<=imc .and. imc<27)
Print*,”Sobrepeso”
Else
If (27<=imc .and. imc<30)
Print*,”Obesidad I”
Else
If (30<=imc .and. imc<40)
Print*,”Obesidad II”
Else
Print*,”Obesidad III”
End if
End if
End if
End if
End if
End program imc

PROBLEMA 5

PROGRAM TELEFONIA_PAGO
INTEGER::T !TIEMPO DE LLAMADA
REAL::RB !RENTA BASICA
PRINT*,"INGRESE EL TIEMPO DE LLAMADA"
READ*,T
PRINT*,"INGRESE EL VALOR DE LA RENTA BASICA"
READ*,RB
IF(T<=50)THEN
VST=RB
ELSEIF(T>50.AND.T<=100)THEN
PC=T*0.1
VST=RB+PC
ELSEIF(T>100.AND.T<=160)THEN
PC=T*0.08
VST=RB+PC
ELSEIF(T>1600)THEN
PC=T*0.05
VST=RB+PC
END IF
IMPUESTO=VST*18/100
VT=VST+IMPUESTO
PRINT*,"EL VALOR SUBTOTAL ES=",VST
PRINT*,"EL VALOR DEL IGV=",IMPUESTO
PRINT*,"EL VALOR TOTAL ES=",VT
END PROGRAM TELEFONIA_PAGO
(AUTOEVALUACION)
Problema 1

PROGRAM ESTADO_CIVIL
INTEGER::N
IF (N==1) THEN
PRINT*,"SOLTERO"
ELSE
IF (N==2) THEN
PRINT*,"CASADO"
ELSE
IF (N==3) THEN
PRINT*,"VIUDO"
ELSE
IF (N==4) THEN
PRINT*,"DIVORCIADO"
END IF
END IF
END IF
END IF
END PROGRAM ESTADO_CIVIL

PROBLEMA 2

PROGRAM CLIMA
REAL::TP
PRINT*,"INGRESE EL VALOR DE LA TEMPERATURA
PROMEDIO"
READ*,TP
IF (TP<10) THEN
PRINT*,"CLIMA FRIO"
ELSEIF (TP<=20) THEN
PRINT*,"CLIMA NUBLADO"
ELSEIF (TP<=30) THEN
PRINT*,"CLIMA CALUROSO"
ELSEIF (TP>30) THEN
PRINT*,"CLIMA TROPICAL"

END IF
END PROGRAM CLIMA

Problema 3
Program clasificacion_fosforo
Real::P
character(len=20)::C
Print*,"Ingresar porcentaje de fosforo"
Read*,P
If (P<0.05) then
C="Bessemer"
Else if (P<=0.18 .and. P>=0.05) then
C="No bessemer"
Else if(P>0.18) then
C="Fosforoso"
End if
Print*,"Imprimir Clasificacion"
Print*,"Clasificacion= ",C
End program clasificacion_fosforo

Problema 4

PROGRAM Prob4
real::VELOC
PRINT*,"INGRESE VELOC"
READ*,VELOC
SELECT CASE(VELOC)
CASE(2.4)
PRINT*,"PLANETA LUNA"
CASE(4.2)
PRINT*,"PLANETA MERCURIO"
CASE(5.3)
PRINT*,"PLANETA PLUTON"
CASE(5.0)
PRINT*,"PLANETA MARTE"
CASE(10.3)
PRINT*,"PLANETA VENUS"
CASE(11.2)
PRINT*,"PLANETA TIERRA"
CASE(22.0)
PRINT*,"PLANETA URANO"
CASE(24.0)
PRINT*,"PLANETA NEPTUNO"
CASE(36.0)
PRINT*,"PLANETA SATURNO"
CASE(61.0)
PRINT*,"PLANETA JUPITER"
END SELECT
END PROGRAM prob4

Problema 5

Program tallos
Real::h
Print*,”Ingrese la altura del tallo en metros”
Read*,h
If (h<=1)
Print*,”Mata”
Else
If (h>1 .and. h<=4)
Print*,”Arbusto”
Else
If (h>4 .and. h<=8)
Print*,”Arbolillo”
Else
Print*,”Arbol”
End if
End if
End if
End program tallo

PROBLEMA 8

PROGRAM PRECIO_LIBRO
REAL::PB,RE,PT
INTEGER::N
PRINT*,"INGRESE EL NUMERO DE HOJAS QUE TIENE EL
LIBRO"
READ*,N

PB=5
IF (N<300)THEN
RE=0.15*N
PRINT*,"RE"
ELSEIF (N<=550) THEN
RE=0.15*N +10
PRINT*,"RE"
ELSEIF (N>550) THEN
RE=0.15*N+10+7.5
PRINT*,"RE"
END IF
PT=PB+RE
PRINT*,"EL PRECIO TOTAL ES ",PT
END PROGRAM PRECIO_LIBRO

Problema 9

Program trabajador
Real::C,M
Real,parameter::S=250
Print*,"Ingrese monto vendido"
Read*,M
If(M>=20000)then
C=0.16*20000
Else if(M>=15000 .and. M<20000) then
C=0.14*20000
Else if(M>=10000 .and. M<15000) then
C=0.12*10000
Else if(M<10000) then
C=0.10*10000
End if
SB=S+C
If(SB>1800) then
D=0.11*SB
Else if(SB<1800) then
D=0*SB
End if
SN=SB-D
Print*,"Imprimir resultados"
Print*,"Sueldo bruto= ", SB
Print*,"Descuento= ",D
Print*,"Sueldo neto= ",SN
End program trabajador

Problema 10

PROGRAM P10
real::P1,P2,P3,P4,P5
REAL::PROM,CATEG
PRINT*,"INGRESE LAS 5 PRACTICAS"
READ*,P1,P2,P3,P4,P5
PROM=(P1+P2+P3+P4+P5)/5
IF(PROM>=17)THEN
PRINT*,"CATEG=A"
ELSE
IF(PROM>=14)THEN
PRINT*,"CATEG=B"
ELSE
IF(PROM>=10)THEN
PRINT*,"CATEG=C"
ELSE
CATEG=D
END IF
END IF
END IF
PRINT*,PROM
END PROGRAM P10
Problema 11
Programa sedapal
Real parameter::pb=3.10
Real::cons
Print*,”Ingrese el consumo”
Read*,cons
If (cons>0 .and. cons<=20)
Pc=cons*0.8
Else
If (cons>20 .and. cons<=30)
Consx=cons-20
Pc=(20*0.8)+(consx*1.11)
Else
If (cons>30 .and. cons<=50)
Consx=cons-30
Pc=(20*0.8)+(10*1.11)+(consx*1.55)
Else
If (cons>50 .and. cons<=80)
Consx=cons-50
Pc=(20*0.8)+(10*1.11)+(20*1.55)+(consx*2.13)
Else
If (cons>80)
Consx=cons-80
Pc=(20*0.8)+(10*1.11)+(20*1.55)+(30*2.13)+(consx*3)
Else
Print*,”Consumo no valido”
End if
End if
End if
End if
End if
Imp=0.18*pc
Pt=pc+imp+pb
Print*,”El costo de la pension básica es “,pb
Print*,”El costo del impuesto es “,imp
Print*,”El costo del consumo del mes es “,pc
Print*,”El costo del importe total es “,pt
End program sedapal
PROBLEMA 12
PROGRAM DETERMINAR_PAGOS
INTEGER::X
REAL::Y
PRINT*,"INGRESE LA CANTIDAD DE DISCOS A COMPRAR"
READ*,X
PRINT*,"INGRESE EL PRECIO DE CADA DISCO"
READ*,Y
IF(X<48)THEN
D=0
ELSEIF(X>=48.AND.X<72)THEN
D=24*Y*10/100
ELSEIF(X>=72.AND.X<96)THEN
D=24*Y*10/100+24*Y*15/100
ELSEIF(X>=96)THEN
D=24*Y*10/100+24*Y*15/100+(X-
72)*Y*20/100
END IF
DES=D
IC=X*Y
IP=IC-D
PRINT*,"EL IMPORTE DE COMPRA ES=",IC
PRINT*,"EL DESCUENTO ES=",DES
PRINT*,"EL IMPORTE A PAGAR ES=",IP
END PROGRAM DETERMINAR_PAGOS

Problema 13

PROGRAM CUADERNOS_LAPICEROS
INTEGER::NC,NOVO,LUCAS,CROSS
IF(NC<=12)THEN
PRINT*,"NINGUN LAPICERO"
ELSE
IF(NC>12.AND.NC<=24)THEN
DO
LUCAS=NC/2
PRINT*,"LUCAS "LUCAS""
END DO
ELSE
IF(NC>24.AND. NC<=36)THEN
DO
CROSS=NC/2
PRINT*,"CROSS "CROSS""
END DO
ELSE
IF (NC>36)THEN
DO
NOVO=NC/2
PRINT*,"NOVO","LUCAS,"CROSS"
END DO
END IF
END IF
END IF
END IF
END PROGRAM CUADERNOS_LAPICEROS

PROBLEMA 14

PROGRAM ORDEN
REAL::A,B,C
PRINT*,"INGRESE EL VALOR DE A"
READ*,A
PRINT*,"INGRESE EL VALOR DE B"
READ*,B
PRINT*,"INGRESE EL VALOR DE C"
READ*,C

IF (A>B .AND. B>C) THEN


PRINT*,"LOS NUMEROS FUERON INGREADOS DE MANERA
DESCENDETE"
ELSEIF (A<B .AND. B<C) THEN
PRINT*,"LOS NUMERO FUERON INGRESADOS DE MANERA
ASCENDENTE"
ELSE
PRINT*,"LOS NUMEROS FUERON INGRESADOS EN
DESORDEN"
END IF
END PROGRAM ORDEN
Problema 15

Program numeros
Real::N
Character(len=20)::CC
Print*,”Ingresar numero”
Read*,N
If(N<=9 .and. N>=-9) then
CC=”1 cifra”
Else if(N<=99 .and. N>=-99) then
CC=”2 cifras”
Else if (N<=999 .and. N>=-999) then
CC=”3 cifras”
Else if(N<=9999 .and. N>=-9999) then
CC=”4 cifras”
End if
Print*,”Imprimir numero de cifras”
Print*,”El numero de cifras= ”,CC
End program números

Problemas propuestos

Problema 2
PROGRAM p2
real::PUNT
REAL::CALIF
PRINT*,"INGRESE LA PUNTUCACION"
READ*,PUNT
IF(PUNT==6)THEN
PRINT*,"EXCELENTE",CALIF
ELSE
IF(PUNT==5)THEN
PRINT*,"MUY BIEN",CALIF
ELSE
IF(PUNT>=3)THEN
PRINT*,"REGULAR",CALIF
ELSE
PRINT*,"PESIMO",CALIF
END IF
END IF
END IF
PRINT*,"CALIFICION ES=",CALIF
END PROGRAM p2

Problema 3

Program libros
Integer::a,b,c,d !a=cons b=is c=ie d=acab
Integer::opción,libro,n,pc
Print*,”Ingrese la cantidad de libros comprados “
Read*,n
Print*,”Compra en la empresa … (1) “
Print*,”Compra a domicilio … (2) “
Read*,opción
Select case (opción)
Case (1)
Print 1
1 format (Construccion …(a),/,Sanitarios …(b),/,Electricas
…(c),/,Acabados …(d))
Read*,libro
Select case (libro)
Case (a)
Pc=n*30
Case (b)
Pc=n*27
Case (c)
Pc=n*20
Case (d)
Pc=n*35
Case default
Print*,”Error”
End select
Case (2)
Print 1
1 format (Construccion …(a),/,Sanitarios …(b),/,Electricas
…(c),/,Acabados …(d))
Read*,libro
Select case (libro)
Case (a)
Pc=n*30*1.02
Case (b)
Pc=n*27*1.02
Case (c)
Pc=n*20*1.02
Case (d)
Pc=n*35*1.02
Case default
Print*,”Error”
End select
Case dafault
Print*,”Error”
End select
End program libros

PROBLEMA 4

PROGRAM PRODUCTOS_PAGOS
INTEGER::P,X,CALIDAD
PRINT*,"INGRESE LA CANTIDAD DE PRODUTOS A COMPRAR"
READ*,X
PRINT*,"INGRESE EL TIPO DE PRODUCTO"
READ*,P !TIPO DE PRODUCTO DEL 1 AL 3
SELECT CASE(P)
CASE(1)
PRINT*,"INGRESE LA CALIDAD"
READ*, CALIDAD !CALIDAD 1 O 2
SELECT CASE(CALIDAD)
CASE(1)
PU=20.0
CASE(2)
PU=18.5
CASE DEFAULT
PRINT*,"LETRA MAL EDITADA"
END SELECT
CASE(2)
PRINT*,"INGRESE LA CALIDAD"
READ*, CALIDAD !CALIDAD 1 O 2
SELECT CASE(CALIDAD)
CASE(1)
PU=30.5
CASE(2)
PU=28.0
CASE DEFAULT
PRINT*,"LETRA MAL EDITADA"
END SELECT
CASE(3)
PRINT*,"INGRESE LA CALIDAD"
READ*, CALIDAD !CALIDAD 1 O 2
SELECT CASE(CALIDAD)
CASE(1)
PU=15.0
CASE(2)
PU=12.5
CASE DEFAULT
PRINT*,"LETRA MAL EDITADA"
END SELECT
CASE DEFAULT
PRINT*,"NUMERO MAL EDITADO"
END SELECT
IST=PU*X
IMPUESTO=IST*19/100
IT=IST+IMPUESTO
PRINT*,"EL IMPORTE SUBTOTAL ES=",IST
PRINT*,"EL IGV ES=",IMPUESTO
PRINT*,"EL IMPORTE TOTAL A PAGAR ES=",IT
END PROGRAM PRODUCTOS_PAGOS

Autoevaluación

Problema 1

PROGRAM DIAS
INTEGER::N
SELECT CASE (N)
CASE (1)
PRINT*,"LUNES"
CASE (2)
PRINT*,"MARTES"
CASE (3)
PRINT*,"MIERCOLES"
CASE (4)
PRINT*,"JUEVES"
CASE (5)
PRINT*,"VIERNES"
CASE (6)
PRINT*,"SABADO"
CASE (7)
PRINT*,"DOMINGO"
DEFAULT
PRINT*,"NO ENCONTRADO"
END SELECT
END PROGRAM DIAS

PROBLEMA 2
PROGRAM EVALUACION

REAL::PRAM1,PRAM2,PRAM3,PRAF1,PRAF2,PRAF3,PRAQ1,PR
AQ2,PRAQ3
REAL::PPM,PPF,PPQ
INTEGER::CURSO !DE 1 A 3

PRINT*,"INGRESE UN NUMERO PARA DETERMINAR EL


CURSO¨"
READ*,CURSO

SELECT CASE (CURSO)


CASE(1)
PRINT*,"MATEMATICAS"
PRINT*,"INGRESE EL VALOR DE LA PRIMERA PRACTICA DE
MATEMATICAS"
READ*,PRAM1
PRINT*,"INGRESE EL VALOR DE LA SEGUNDA PRACTICA DE
MATEMATICAS"
READ*,PRAM2
PRINT*,"INGRESE EL VALOR DE LA TERCERA PRACTICA DE
MATEMATICAS"
READ*,PRAM3
PPM=(PRAM1 + 2*PRAM2+ 3*PRAM3)/6
PRINT*,"EL PROMEDIO PONDERARADO PARA
MATEMATICAS ES",PPM

IF (PPM>=13)THEN
PRINT*,"EL ALUMNO ESTA APROBADO EN MATEMATICAS "
ELSE
PRINT*,"EL ALUMNO ESTA DESAPROBADO EN
MATEMATICAS"
END IF

CASE(2)
PRINT*,"FISICA"
PRINT*,"INGRESE EL VALOR DE LA PRIMERA PRACTICA DE
FISICA "
READ*,PRAF1
PRINT*,"INGRESE EL VALOR DE LA SEGUNDA PRACTICA DE
FISICA "
READ*,PRAF2
PRINT*,"INGRESE EL VALOR DE LA TERCERA PRACTICA DE
FISICA "
READ*,PRAF3
PPF=(PRAF1 + PRAF2+ 2*PRAF3)/4
PRINT*,"EL PROMEDIO PONDERARADO PARA FISICA ES
",PPF
IF (PPF>=13)THEN
PRINT*,"EL ALUMNO ESTA APROBADO EN FISICA"
ELSE
PRINT*,"EL ALUMNO ESTA DESAPROBADO EN FISICA"
END IF
CASE(3)
PRINT*,"QUIMICA"
PRINT*,"INGRESE EL VALOR DE LA PRIMERA PRACTICA DE
QUIMICA"
READ*,PRAQ1
PRINT*,"INGRESE EL VALOR DE LA SEGUNDA PRACTICA DE
QUIMICA"
READ*,PRAQ2
PRINT*,"INGRESE EL VALOR DE LA TERCERA PRACTICA DE
QUIMICA"
READ*,PRAQ3
PPQ=(PRAQ1 + PRAQ2+ PRAQ3)/3
PRINT*,"EL PROMEDIO PONDERARADO PARA QUIMICA ES
",PPQ
IF (PPQ>=13)THEN
PRINT*,"EL ALUMNO ESTA APROBADO EN QUIMICA"
ELSE
PRINT*,"EL ALUMNO ESTA DESAPROBADO EN QUIMICA"
END IF
CASE DEFAULT
PRINT*,"VALOR NO VALIDO"
END SELECT
END PROGRAM EVALUACION

Problema 3

Program cine
Real::PPG,PN,EPG,EN,N,M
Real::T
integer::dia
Print*,"Ingresar numero para determinar el dia"
Read*,dia
Select case(dia)
case(1)
print*,"Lunes"
PPG=9
PN=7
case(2)
print*,"Martes"
PPG=7
PN=7
case(3)
print*,"Miercoles,Jueves,Viernes"
PPG=10
PN=8
case(4)
print*,"Sabado,Domingo"
PPG=12
PN=9
End select
Print*,"Ingresar numeros de entrada publico general"
Read*,EPG
Print*,"Ingresar numero de entradas niños"
Read*,EN
N=EPG+EN
If(N>5) then
M=PPG/2
Else if(N<=5) then
M=0
End if
T=(PPG*EPG)+(PN*EN)-M
Print*,"Total a pagar= ",T
End program cine

Problemas propuestos acividad

Problema 1
program P1
implicit none
integer::i, j
PRINT*,"IMPRESION DE TERMINOS“
do i=1, 200, 1
PRINT*,i
end do
stop
end program P1

problema 2

Program suma_50
Integer::i,suma,n
Suma=0
Do i=1,50
N=i*2
Suma=suma+n
Print*,”Los términos son: ”
Print*,n
Print*
End do
Print*,”La suma es “,suma
End program suma_50

PROBLEMA 3
PROGRAM SUMA
REAL::S
S=0
DO I=1,100
S=S+(3.0*I-1)/(2*I+1)
PRINT*, (3.0*I-1)/(2*I+1)
END DO
PRINT*,"LA SUMA DE LA SERIE ES=",S
END PROGRAM SUMA

Problema 4

PROGRAM SUMA_N
REAL::I,P,Q,N,M,SUM=0
I=0 ,I=M-1
DO
P=1+(3*I)
Q=2+(2*I)
N=P/Q
PRINT*," P"/"Q"\N" "
END DO
DO
SUM=SUM+N
PRINT*,"SUM"
END PROGRAM SUMA_N

Problema 16
PROGRAM TABLA
IMPLICIT NONE
REAL::N,10**1*N,10**2*N,10**3*N,10**4*N
PRINT 1000
1000
FORMAT(8X,"N",7X,"10**1*N",7X,"10**2*N",7X,"10**3*N,7X,"10**4*
N)
DO N=1,2,3,4,5,6,7,8,9
10**1*N=10**1*N
10**2*N=10**2*N
10**3*N=10**3*N
10**4*N=10**4*N
PRINT 100,N,10**1*N,10**2*N,10**3*N,10**4*N
END DO
100 FORMAT(1X,F8.3,2X,F8.3,2X,F8.3,2X,F8.3,2X,F8.3)
END PROGRAM TABLA

PROBLEMA 4 DE LA PAGINA 166(ESTRUCTURA DE


REPETICION)

PROGRAM SUMA_N
INTEGER::I,X
REAL::S
PRINT*,"INGRESE EL VALOR DE X"
READ*,X
S=0
DO I=0,X
S=S+(5.0*I+1)/(4.0*I+1)
END DO
PRINT*,"LA SUMA DE LA SERIE ES=",S
END PROGRAM SUMA_N

PROBLEMA 10 DE LA PAGINA 167(ESTRUCTURA DE


REPETICION)

PROGRAM PROYECTIL
INTEGER::T
REAL::H
PRINT*,"TIEMPO ALTURA"
DO WHILE(T>=0.AND.T<=20)
H=50+200*T+5*(T**2)
PRINT*,T,H
T=T+2
END DO
END PROGRAM PROYECTIL

06)PAG 166 (AUTOEVALUACION)

PROGRAM PI
REAL::N
I=1
PI=0
DO WHILE (I<=N)
ST=(4*(-1)**(I+1)/2*I+1)
PI=PI+ST
I=I+1
END DO
PRINT*,"PI",PI
END PROGRAM PI

12)PAG 166(AUTOEVALUACION)

PROGRAM PRIMO
REAL::N,DIV,PRIMO,PRUEBA
DIV=2
PRIMO=0
PRUEBA=N MOD DIV
DO(PRUEBA=0)
PRIMO=PRIMO+1
DIV=DIV+1
ELSE
DO(DIV=DIV+1)
N=1 .AND. N=DIV
END DO
END DO
IF (PRIMO=0) THEN
PRINT*,"SI"
ELSE
PRINT*,"NO"
END IF
END PROGRAM PRIMO

18) PAG 168 (AUTOEVALUACION)

PROGRAM AL_REVES
INTEGER:: NUM, ALREVES, UNI,DEC,CE,MI
PRINT*,"INGRESAR NUMERO"
READ*,NUM
MI = NUM/100%10
CE = NUM/100
DEC= NUM/10%10
UNI= NUM%10
ALREVES = UNI *1000+ DEC*100 + CE*10 + MI
PRINT*,"EL NUMERO AL REVES ES",ALREVES
END PROGRAM AL_REVES

Problema 8
Program filas_10
Integer::i
Do i=1,100
If (mod(i,10)==0)
Print*
Print*,i
Else
Print*,i
End if
End do
End program filas_10
Problema 3
Program suma_n
Integer::i,n
Real::suma,t
Print*,”Ingrese el termino enésimo”
Read*,n
Suma=1
Do i=1,n
T=(i+5)/(i+4)
Suma=suma+t
End do
Print*,suma
End program suma_n

Program proyectil
Integer::i,t
Real::h
Do i=1,21,2
T=i-1
H=50+200*t+5*(t**2)
Print*,t,h
End do
End program proyectil

Problema 22
Program primos
Integer::p,i,c
C=0
P=1
Do while (p<=10)
Do i=1,p
If (mod(p,i)==0)
C=c+1
End if
End do
If (c<=2)
Print*,p
Print*
End if
P=p+1
End do
End program primos

Problema 22
Program pirámide
Integer::i
Do i=1,10
Print*,”%”
Print*
End do
End program pirámide

Vous aimerez peut-être aussi