Foro de programación en PHP
Ayudanme Urgente a realizar este programa en PHP
| Autor: Dennis Fernandez Publicado: 10-10-2009 12:28 PM |
|
|
Desarrolle un programa en PHP recorra con un ciclo 5 sueldos y edades. Calcular la suma de los salarios y edades. Calcular cuantos empleados estan entre 20 y 30, 31 y 40. Calcular la suma de los salarios de estas edades y determinar cual rango tiene el mayor sueldo promedio. Ayudenme porfavor urgente mandenme el codigo a fernandezmorell83@hotmail.com Atte; Dennis G. Fernández |
|
| Autor: dcreate Publicado: 15-10-2009 03:13 PM |
|
| yo lo hago de esta manera: index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Documento sin título</title> </head> <body> <form id="form1" name="form1" method="post" action="procesar.php"> <table width="355" border="1"> <tr> <td width="144"><label> <input name="sueldo1" type="text" id="sueldo1" /> </label></td> <td width="195"><label> <input name="edad1" type="text" id="edad1" /> </label></td> </tr> <tr> <td><label> <input name="sueldo2" type="text" id="sueldo2" /> </label></td> <td><label> <input name="edad2" type="text" id="edad2" /> </label></td> </tr> <tr> <td><label> <input name="sueldo3" type="text" id="sueldo3" /> </label></td> <td><p> <label> <input name="edad3" type="text" id="edad3" /> </label> </p> </td> </tr> <tr> <td><label> <input name="sueldo4" type="text" id="sueldo4" /> </label></td> <td><label> <input name="edad4" type="text" id="edad4" /> </label></td> </tr> <tr> <td><label> <input name="sueldo5" type="text" id="sueldo5" /> </label></td> <td><label> <input name="edad5" type="text" id="edad5" /> </label></td> </tr> </table> <p> <label> <input type="submit" name="Submit" value="Enviar" /> </label> </p> </form> </body> </html> procesa.php <?php for($i=1;$i<=5;$i++) { $sueldo[$i]=$_POST['sueldo'.$i]; $edad[$i]=$_POST['edad'.$i]; $suma=$suma+$sueldo[$i]; if($edad[$i]>=20 && $edad[$i]<=30) { $con++; $sal=$sal+$sueldo[$i]; } if($edad[$i]>=31 && $edad[$i]<=40) { $con1++; $sal1=$sal1+$sueldo[$i]; } } echo "<B>EDADES ENTRE 20 Y 30:</B> "."<i>".$con."</i>"." <B>SUMA DE SALARIOS: </B>".$sal."<br>"; echo "<b>EDADES ENTRE 31 Y 40: </b>"."<i>".$con1."</i>"." <B>SUMA DE SALARIOS: </B>".$sal1."<br>"; echo "SALARIO TOTAL: ".$suma; if($sal>$sal1) { echo "<br><b>LAS EDADES ENTRE 20 Y 30 TIENEN MAYOR SUELDO</b>"; } else { echo "<br><b>LAS EDADES ENTRE 31 Y 40 TIENEN MAYOR SUELDO</b>"; } ?> espero te sirva :-p |
|

