Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Vinicius Zanetti

Problemas com respostas de um código para gerar média de somas

Recommended Posts

Caso algum de vocês puderem me ajudar, estou com problemas para desenvolver a Atividade, escolhi escrever um script para média de notas, porém ele está concatenando ao invés de somar, e a resposta é sempre "aluno reprovado"
Segue códigos:

<!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=utf-8" />
<title>calculo_media</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="response_media.asp">
<p><strong>Nome:</strong></p>
<label for="Nome"></label>
<input type="text" name="Nome" id="Nome" />
<p>Nota do primeiro bimestre:
<label for="n1"></label>
<input type="text" name="n1" id="n1" /></p>
<p>Nota do segundo bimestre:
<label for="n2"></label>
<input type="text" name="n2" id="n2" /></p>
<p>Nota do terceiro bimestre:
<label for="n3"></label>
<input type="text" name="n3" id="n3" /></p>
<p>
<input type="submit" name="enviar" id="enviar" value="Enviar" />
<input type="reset" name="limpar" id="limpar" value="Limpar" /> </p>
</form>
<p> </p>

</body>
</html>



<% Option Explicit %>
<!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=utf-8" />
<title>response_calculo_media</title>
<%
Dim a,b,c,d,nota
a=Request.Form("n1")
b=Request.Form("n2")
c=Request.Form("n3")
d=(a+b+c)
nota= d/3
%>

<%
if nota < 5 then 'comparação entre dois valores
response.write ("A nota foi " & nota &": aluno reprovado!")'
'

else

if nota > 5 then 'comparação entre dois valores
response.write ("A nota foi " & nota &": aluno reprovado!")'
'
end if
end if
%>

</head>
<body>
</body>
</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Vinicius,

 

O problema está no seu código, nas duas opções ele está configurado para mostrar aluno reprovado

if nota < 5 then 'comparação entre dois valores
response.write ("A nota foi " & nota &": aluno reprovado!")'
'

else

if nota > 5 then 'comparação entre dois valores
response.write ("A nota foi " & nota &": aluno reprovado!")'

Compartilhar este post


Link para o post
Compartilhar em outros sites

Desculpe, não reparei que descrevi no código reprovado duas vezes, corrigi e deu tudo certo, obrigado.

"

Ser feliz sem motivo é a mais autêntica forma de felicidade."

 

Carlos Drumont de Andrade

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.