Advertisement
Guest User

Untitled

a guest
Dec 15th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.84 KB | None | 0 0
  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  2.     pageEncoding="ISO-8859-1"%>
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6. <meta charset="ISO-8859-1">
  7. <title>Fórum Temático 1</title>
  8. <style>
  9. table, th, td {
  10.     border: 1px solid black;
  11.     text-align: center;
  12. }
  13. </style>
  14. </head>
  15. <body>
  16.     <h2>Fórum Temático 1</h2>
  17.     <form>
  18.         Nome:<input type="text" name="nome"><br>
  19.         Nota 1:<input type="number" name="nota1" step="0.01"><br>
  20.         Nota 2:<input type="number" name="nota2" step="0.01"><br>
  21.         Nota 3:<input type="number" name="nota3" step="0.01"><br>
  22.         <input type="submit" value="Calcular"><br />
  23.     </form>
  24.     <table style="width: 100%">
  25.         <tr>
  26.             <th>Nome</th>
  27.             <th>Nota 1</th>
  28.             <th>Nota 2</th>
  29.             <th>Nota 3</th>
  30.             <th>Média</th>
  31.             <th>Situação</th>
  32.         </tr>
  33.         <br><br>
  34.         <tr>
  35.             <td><%=request.getParameter("nome")%></td>
  36.             <td><%=request.getParameter("nota1")%></td>
  37.             <td><%=request.getParameter("nota2")%></td>
  38.             <td><%=request.getParameter("nota3")%></td>
  39.             <td>
  40.                 <%
  41.                     String situacao = "Aguardando notas";
  42.                     String nota1 = request.getParameter("nota1");
  43.                     String nota2 = request.getParameter("nota2");
  44.                     String nota3 = request.getParameter("nota3");
  45.                     if (nota1 != "" && nota2 != "" && nota3 != "" && nota1 != null && nota2 != null && nota3 != null) {
  46.                         double notaMedia = (Double.parseDouble(nota1) + Double.parseDouble(nota2) + Double.parseDouble(nota3))
  47.                                 / 3;
  48.                         java.util.Formatter formatter = new java.util.Formatter();
  49.                         formatter.format("%.2f", notaMedia);
  50.                         out.print("" + notaMedia);
  51.                         if (notaMedia >= 7) {
  52.                             situacao = "Aprovado";
  53.                         } else {
  54.                             situacao = "Reprovado";
  55.                         }
  56.                     } else {
  57.                         out.print("Insira os dados e clique em calcular");
  58.                     }
  59.                 %>
  60.             </td>
  61.             <td><%=situacao%></td>
  62.         </tr>
  63.     </table>
  64.     <br>
  65. </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement