Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="ISO-8859-1">
- <title>Fórum Temático 1</title>
- <style>
- table, th, td {
- border: 1px solid black;
- text-align: center;
- }
- </style>
- </head>
- <body>
- <h2>Fórum Temático 1</h2>
- <form>
- Nome:<input type="text" name="nome"><br>
- Nota 1:<input type="number" name="nota1" step="0.01"><br>
- Nota 2:<input type="number" name="nota2" step="0.01"><br>
- Nota 3:<input type="number" name="nota3" step="0.01"><br>
- <input type="submit" value="Calcular"><br />
- </form>
- <table style="width: 100%">
- <tr>
- <th>Nome</th>
- <th>Nota 1</th>
- <th>Nota 2</th>
- <th>Nota 3</th>
- <th>Média</th>
- <th>Situação</th>
- </tr>
- <br><br>
- <tr>
- <td><%=request.getParameter("nome")%></td>
- <td><%=request.getParameter("nota1")%></td>
- <td><%=request.getParameter("nota2")%></td>
- <td><%=request.getParameter("nota3")%></td>
- <td>
- <%
- String situacao = "Aguardando notas";
- String nota1 = request.getParameter("nota1");
- String nota2 = request.getParameter("nota2");
- String nota3 = request.getParameter("nota3");
- if (nota1 != "" && nota2 != "" && nota3 != "" && nota1 != null && nota2 != null && nota3 != null) {
- double notaMedia = (Double.parseDouble(nota1) + Double.parseDouble(nota2) + Double.parseDouble(nota3))
- / 3;
- java.util.Formatter formatter = new java.util.Formatter();
- formatter.format("%.2f", notaMedia);
- out.print("" + notaMedia);
- if (notaMedia >= 7) {
- situacao = "Aprovado";
- } else {
- situacao = "Reprovado";
- }
- } else {
- out.print("Insira os dados e clique em calcular");
- }
- %>
- </td>
- <td><%=situacao%></td>
- </tr>
- </table>
- <br>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement