Advertisement
vago

Untitled

Jun 24th, 2022
732
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None
  1. import jakarta.servlet.ServletException;
  2. import jakarta.servlet.annotation.WebServlet;
  3. import jakarta.servlet.http.HttpServlet;
  4. import jakarta.servlet.http.HttpServletRequest;
  5. import jakarta.servlet.http.HttpServletResponse;
  6. import java.io.IOException;
  7. import java.io.PrintWriter;
  8.  
  9.  
  10. /**
  11.  * Servlet implementation class nota
  12.  */
  13. public class nota extends HttpServlet {
  14.     private static final long serialVersionUID = 1L;
  15.        
  16.     /**
  17.      * @see HttpServlet#HttpServlet()
  18.      */
  19.     public nota() {
  20.         super();
  21.         // TODO Auto-generated constructor stub
  22.     }
  23.  
  24.     /**
  25.      * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
  26.      */
  27.     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  28.         // TODO Auto-generated method stub
  29.         response.getWriter().append("Served at: ").append(request.getContextPath());
  30.        
  31.         response.setContentType("text/html");
  32.         PrintWriter out = response.getWriter();
  33.        
  34.         out.println("<html>");
  35.         out.println("<body>");
  36.        
  37.         String nome = request.getParameter("nome");
  38.         double nota1 = Double.parseDouble(request.getParameter("nota1"));
  39.         double nota2 = Double.parseDouble(request.getParameter("nota2"));
  40.         double nota3 = Double.parseDouble(request.getParameter("nota3"));
  41.         double nota4 = Double.parseDouble(request.getParameter("nota4"));
  42.         Double resultado = (nota1 + nota2 + nota3 + nota4) / 4;
  43.        
  44.        
  45.         out.println("Aluno: "+nome+" | "+" Media: "+resultado);
  46.        
  47.         out.println("</body>");
  48.         out.println("</html>");
  49.     }
  50.  
  51.    
  52.  
  53. }
  54.  
Advertisement
RAW Paste Data Copied
Advertisement