简单的考试系统

开发一个简单的考试系统,在HTML页面中建立一个表单,通过post方法传递参数。题目类型包括单选题、多选题和填空题,要求程序给出考试成绩。




    question.html
    


请回答下面问题: 
1.Windows操作系统是那家公司产品? apple公司 IBM公司 Microsoft公司
2.下列设计语言,那些事面向对象的? java语言 c语言 c++语言
3.编写Servlet程序应该继承那个类?
4.下图是那种编程语言的图标? c++ python java
交卷请单击 重新交卷请单击
package com.demo;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

import javax.jws.WebService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(urlPatterns = "/quetionForm")
public class ExamServlet extends HttpServlet{


    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }


    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        resp.setContentType("text/html;charset=UTF-8");
        PrintWriter out = resp.getWriter();
        String cooperation = req.getParameter("cooperation");
//		out.println("1 "+cooperation);
        String language1 = req.getParameter("language1");
        String language2 = req.getParameter("language2");
        String language3 = req.getParameter("language3");
//		out.println(" 2 "+language1);
        String impClass = req.getParameter("impClass");
//		out.println(" 3 "+impClass);
        String languagelogo = req.getParameter("languagelogo");
//		out.println("4 "+languagelogo);
        int sum = 0;
        try {
            if(cooperation.equals("Microsoft"))
                sum += 25;
            if(language1.equals("java") && language3.equals("c++") ){
                sum += 25;
                if(language2 != null)
                    sum -= 25;
            }
            if(impClass.equals("HttpServlet"))
                sum += 25;
            if(languagelogo.equals("java"))
                sum += 25;
        } catch (Exception e) {
            out.print("请选择正确的答案");
        }
// 		out.println("cooperation ==> "+cooperation +"\n"+
// 				"language ==> "+ language  + "\n"+
// 				"impClass ==> "+ impClass +  "\n"+
// 				"languagelogo ==> "+ languagelogo + "\n"
// 				+ "sum = "+sum);
        out.println("");
        out.println("");
        out.println("  result");
        out.println("  ");
        out.print("     ");
        out.println("result == " +sum);
        out.println("  ");
        out.println("");
        out.flush();
        out.close();
    }
}

简单的考试系统_第1张图片

简单的考试系统_第2张图片 

你可能感兴趣的:(hive,hadoop,数据仓库)