Rendimiento mensual
Publicado por test (4 intervenciones) el 27/05/2019 21:03:53
Buenas tardes
Estoy tratando de realizar un programa que me ayude a generar el rendimiento anual y que me lo sume en una tabla, hasta el momento ya puede realizar las operaciones basándome en el código de un compañero del sitio pero no logro a acomodar los resultados en las tablas.
Me podrian ayudar.
Estoy tratando de realizar un programa que me ayude a generar el rendimiento anual y que me lo sume en una tabla, hasta el momento ya puede realizar las operaciones basándome en el código de un compañero del sitio pero no logro a acomodar los resultados en las tablas.
Me podrian ayudar.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
if(isset($_POST["interes"]))
{
$_POST["interes"]=str_replace(",",".",$_POST["interes"]);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>cálculo de hipotecas/préstamos</title>
</head>
<style>
form {width:250px;}
form>div>span {width:100px;display: inline-block;text-align:left;}
form input {width:150px;}
form>div {text-align:center;}
</style>
<body>
<h1>Cálculo de hipotecas/préstamos</h1>
<form action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST">
<div>
<span>Importe :</span>
<span><input type="text" name="importe" maxlength=9 value="<?php echo $_POST["importe"]?>"></span>
</div>
<div>
<span>Años :</span>
<span><input type="text" name="anos" maxlength=2 value="<?php echo $_POST["anos"]?>"></span>
</div>
<div>
<span>Interés :</span>
<span><input type="text" name="interes" maxlength=9 value="<?php echo $_POST["interes"]?>"></span>
</div>
<div>
<p><input type="submit" value="Calcular"></p>
</div>
</form>
<?php
if($_POST["importe"] && $_POST["anos"] && $_POST["interes"])
{
$deuda=$_POST["importe"];
$anos=$_POST["anos"];
$interes=$_POST["interes"];
// hacemos los calculos...
$interes=($interes/100);
$rendimiento1=($deuda/100)*$interes;
$m=($deuda*(pow((1+$interes),($anos))));
$d=$deuda*$interes;
$d2=$d/12;
$a=$años*12;
echo "<div>Capital Inicial: ".number_format($deuda,2,",",".")." €";
echo "<br>Cuota a pagar mensualmente: ".number_format($m,2,",",".")." €</div>";
?>
<table border=1 cellpadding=5 cellspacing=0>
<tr>
<th>Mes</th>
<th>interes</th>
<th>Ganancia</th>
<th>Capital Pendiente</th>
</tr>
<?php
// mostramos todos los meses...
for($i=1;$i<=$anos*12;$i++)
{
echo "<tr>";
echo "<td align=right>".$i."</td>";
$totalint=$capital+$d2;
echo "<td align=right>".number_format($capital+$rendimiento1,2,",",".")."</td>";
echo "<td align=right>".number_format($totalint,2,",",".")."</td>";
$capital=$capital+$rendimiento1;
if ($rendimiento1>=$m)
{
echo "<td align=right>0</td>";
}else{
echo "<td align=right>".number_format($totalint,2,",",".")."</td>";
}
echo "</tr>";
}
?>
</table>
Pago total de intereses : <?php echo number_format($m,2,",",".")?> $
<?php
}
?>
</body>
</html>
Valora esta pregunta


0