Se requiere que por medio de formularios se ingresen los datos tanto de las materias como de las calificaciones y que se lance un cuadro de dialogo (alert) con los datos ingresados, calculando el promedio y determinando si el alumno esta aprobado o reprobado.
Código: | |
<html> <head> | |
</head> | |
<body bgcolor="red"> | |
<center><h1>Promedios</h1></center> | |
<script type="text/javascript"> | |
function mostrar() | |
{ | |
var nombre=document.getElementById('nombre').value; | |
var m1=document.getElementById('m1').value; | |
var m2=document.getElementById('m2').value; | |
var m3=document.getElementById('m3').value; | |
var m4=document.getElementById('m4').value; | |
var m5=document.getElementById('m5').value; | |
var c1=document.getElementById('c1').value; | |
var c2=document.getElementById('c2').value; | |
var c3=document.getElementById('c3').value; | |
var c4=document.getElementById('c4').value; | |
var c5=document.getElementById('c5').value; | |
var promedio = (parseInt(c1) + parseInt(c2) + parseInt(c3) + parseInt(c4) +parseInt(c5))/5; | |
if(promedio<=6) | |
{ | |
alert('Nombre'+nombre+'\n'+'\n'+'Materia:'+m1+'\n'+'Calificacion:'+c1+'\n'+'\n' | |
+'Materia:'+m2+'\n'+'Calificacion:'+c2+'\n'+'\n' | |
+'Materia:'+m3+'\n'+'Calificacion:'+c3+'\n'+'\n' | |
+'Materia:'+m4+'\n'+'Calificacion:'+c4+'\n'+'\n' | |
+'Materia:'+m5+'\n'+'Calificacion:'+c5+'\n'+'\n' | |
+'Promedio:'+promedio+'\n' | |
+'Estado:Reprobado'); | |
} | |
else | |
{ | |
alert('Nombre'+nombre+'\n'+'\n'+'Materia:'+m1+'\n'+'Calificacion:'+c1+'\n'+'\n' | |
+'Materia:'+m2+'\n'+'Calificacion:'+c2+'\n'+'\n' | |
+'Materia:'+m3+'\n'+'Calificacion:'+c3+'\n'+'\n' | |
+'Materia:'+m4+'\n'+'Calificacion:'+c4+'\n'+'\n' | |
+'Materia:'+m5+'\n'+'Calificacion:'+c5+'\n'+'\n' | |
+'Promedio:'+promedio+'\n' | |
+'Estado:Aprobado'); | |
} | |
} | |
</script> | |
<form> | |
Ingrese su nombre: | |
<input type="text" id="nombre"><br><br> | |
Ingrese Materia 1: | |
<input type="text" id="m1"> | |
Ingrese calificacion: | |
<input type="text" id="c1"><br><br> | |
Ingrese Materia 2: | |
<input type="text" id="m2"> | |
Ingrese calificacion: | |
<input type="text" id="c2"><br><br> | |
Ingrese Materia 3: | |
<input type="text" id="m3"> | |
Ingrese calificacion : | |
<input type="text" id="c3"><br><br> | |
Ingrese Materia 4: | |
<input type="text" id="m4"> | |
Ingrese calificacion: | |
<input type="text" id="c4"><br><br> | |
Ingrese Materia 5: | |
<input type="text" id="m5"> | |
Ingrese calificacion: | |
<input type="text" id="c5"><br><br> | |
<input type="button" value="Promediar" onClick="mostrar()"> | |
</form> | |
</body> | |
</html> | |
No hay comentarios:
Publicar un comentario