TRABAJO COLABORATIVO 1
INTRODUCCION
Pagina index
ACTIVIDAD No. 1
Realizar un programa que me indique el factorial de un nmero capturado por el
teclado.
Ejemplo
Numero 4
El factorial de 4 es 24
Otro ejemplo
Numero 6
El factorial de 6 es 720
SOLUCION
</form>
</center>
<center>
<?php
if(isset($_REQUEST['numero']))
{
ACTIVIDAD No. 2
Realizar un programa que analice si un numero de tres cifras es capica, esto quiere
decirque se leen al derecho y al revs y son iguales, tiene que ser un numero entre
el 100 y 999.
Ejemplo
Numero 343
El numero 343 es un numero capica
Ejemplo
534
El numero 343 no es un numero capica
DESARROLLO
<?php
include ("funciones.php");?>
<html>
<head>
<title>Capicua</title>
</head>
<center>
<h1>Capicua</h1>
<h3>ingrese numero a validar</h3>
<form action="capicua.php" method="post">
<input name="txtnumero" />
<input name="" type="submit" value="verificar"/><body>
</form>
<?php
if(isset($_REQUEST['txtnumero']))
{
capicua($_REQUEST['txtnumero']);
}
?>
</body></center></html>
ACTIVIDAD No. 3
Realizar el simulador del comportamiento de un crdito bancario de la siguiente manera,
donde como datos solicitan el monto del crdito, el tiempo en meses y el tipo de crdito,
donde existen 3, de vivienda, vehculo y libre inversin.
SOLUCION
<?php include ("funciones.php");?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simulador Bancario</title>
</head>
<body>
<center>
<h2>Simulador Bancario de Credito</h2>
<form action="simulador.php" method="post">
<table width="300" border="1">
<tr>
<th scope="col">Monto de Credito</th>
<th scope="col">
<input type="text" name="monto" id="monto"></th>
</tr>
<tr>
<th scope="row">Tipo Credito</th>
<td><input name="radio" type="radio" value="vivienda"
checked><label>Vivienda 1.0 %</label><br><input name="radio" type="radio"
value="vehiculo" ><label>Vehiculo 1,3 %</label><br>
<input name="radio" type="radio" value="libreinversion" ><label>Libre Inversin
2,3 %</label>
<label for="checkbox"></label></td>
</tr>
<tr>
<th scope="row">Tiempo en meses</th>
<td>
<input type="text" name="tiempo" id="textfield"></td>
</tr>
<tr>
<th colspan="2" scope="row"><input type="submit" name="button"
value="Calcular"></th>
</tr>
</table>
</form>
<?php
if(isset($_REQUEST['monto']))
{
echo credito($_REQUEST['monto'],$_REQUEST['radio'],$_REQUEST['tiempo']);
}
?>
</center>
</body>
</html>
FUNCIONES
<?php
// este metodo guarda todos los metodos para la reallizacion de ejercicios
function factorial($numero){
if($numero==0)
{
return 1;
}else{
for($i = $numero-1; $i > 0; $i--)
$numero *= $i;
return $numero;
}
}
function capicua($numero){
if($numero=="")
{
echo "";
}
else
{
$numero2 = strrev($numero);
if($numero==$numero2)
{
echo "Ingreso $numero SI es capicua";
}
else
{
echo "Ingreso $numero NO es capicua";
}
}
}
function credito($monto, $tipo_interes, $tiempo)
{
if(($monto=="")or($tiempo==""))
return "";
$cadena="<table width='200' border='1'>
<tr>
<th scope='col'>Monto</th>
<th scope='col'>".$monto."</th>
</tr>
<tr>
<th scope='row'>Tasa de Interes</th>
<td>".tipo_interes($tipo_interes)." % </td>
</tr>
<tr>
<th scope='row'>Tiempo</th>
<td>".$tiempo."</td>
</tr>
</table>";
$intereses=tipo_interes($tipo_interes);
for($i=0;$i<=$tiempo_2;$i++)
{
$cadena2.="<tr><td>".$i."</td><td>".$cuota."</td><td>".$interes_mensual."
</td><td>".$abono_capital."</td><td>".$saldo."</td></tr>";
$interes_mensual=round(($saldo*$intereses),2);
$abono_capital=round($cuota-$interes_mensual,2);
$saldo=round(($saldo-$abono_capital),2);
}
$cadena2.="</table>";
return $cadena."<br>".$cadena2;
}
function tipo_interes($tipo_interes)
{
if($tipo_interes=="vivienda")
return 0.01;
if($tipo_interes=="vehiculo")
return 0.013;
if($tipo_interes=="libreinversion")
return 0.023;
}
CONCLUSIONES
BIBLIOGRAFA
Salazar Ziga Jorge Eduardo, Puentes Andrade Orlando y Robles Puentes Yhon
Jerson. . Mdulo de Programacin de Sitios Web - PHP. Universidad Nacional
Abierta y a Distancia.