• 软件工程个人作业04


    软件工程个人作业04

    设计思想:

    在写代码的过程中将代码分为三部分,一部分写选择的要求,将要求提交进行审核,确定后,显示答题的界面再将计算进行答题,最后总结结果

    代码:

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>四则运算个性定制</title>
    </head>
    <body>
        <h1>小学四则运算</h1>
            <form action="main1.jsp" method="post">
                
             
                    <p>是否有乘除法
                        <input type="radio" name="chengchu" value=0 >yes
                        <input type="radio" name="chengchu" value=1>no
                     
                    <p>是否有括号
                        <input type="radio" name="kuohao" value=0 >yes
                        <input type="radio" name="kuohao" value=1>no
                     
                    <p>数值范围 
                        <input type="radio" name="fanwei" value=0 >0~10
                        <input type="radio" name="fanwei" value=1 checked>0~100
                 
                    <p>加减有无负数
                        <input type="radio" name="fushu" value=0 >yes
                        <input type="radio" name="fushu" value=1>no
                 
                    <p>除法有无余数     
                        <input type="radio" name="yushu" value=0>yes
                        <input type="radio" name="yushu" value=1>no
             
                    <P>数量
                        <input type="text" name="num">
                <br>        
                <input type="submit" value="答题">
                <input type="reset" value="清除">
              
        </form>
               
        
    </body>
    </html>
    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <%@ page import="java.util.Random "%>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body >
    
            <%!
            public static int RandomNum(int i)
            {
                Random a=new Random();
                int a1=a.nextInt (i);
                return a1;
            }
            %>
            <%
                String snum ;
                String choice[]=new String[5];
                int inum;
                Boolean choice1[]=new Boolean[5]; 
                int result;
            %>
            <% 
                snum=request.getParameter("num");
                
                try{
                    inum=Integer.valueOf(snum);
                    
                }catch(NumberFormatException e){
                    out.println("请输入数字!");
                    inum=new Integer(0);
                }
                choice[0]=request.getParameter("chengchu");
                
                if(choice[0]==null){
                    out.println("请选择是否有乘除法");
                    
                }
                else{
                    if(choice[0].equals("0")){
                        choice1[0]=true;
                    }
                    if(choice[0].equals("1")){
                        choice1[0]=false;
                    }
                }
                choice[1]=request.getParameter("kuohao");
                
                if(choice[1]==null){
                    out.println("请选择是否有括号");
                    
                }
                else{
                    if(choice[1].equals("0")){
                        choice1[1]=true;
                    }
                    if(choice[1].equals("1")){
                        choice1[1]=false;
                    }
                }
                choice[2]=request.getParameter("fanwei");
                
                if(choice[2]==null){
                    out.println("请选择数值范围");
                
                }
                else{
                    if(choice[2].equals("0")){
                        choice1[2]=true;
                    }
                    if(choice[2].equals("1")){
                        choice1[2]=false;
                    }
                }
                choice[3]=request.getParameter("fushu");
                
                if(choice[3]==null){
                    out.println("请选择加减是否有负数");
                
                }
                else{
                    if(choice[3].equals("0")){
                        choice1[3]=true;
                    }
                    if(choice[3].equals("1")){
                        choice1[3]=false;
                    }
                }
                choice[4]=request.getParameter("yushu");
                
                if(choice[4]==null){
                    out.println("请选择除法是否有余数");
                    
                }
                else{
                    if(choice[4].equals("0")){
                        choice1[4]=true;
                    }
                    if(choice[4].equals("1")){
                        choice1[4]=false;
                    }
                }
            %>
            <%
                if(choice[0]==null||choice[1]==null||choice[2]==null||choice[3]==null||choice[4]==null||inum==0){             
                
                }
                else{
                    
                            
                            
                            int a1,a2,sign;
                            a1=RandomNum(100);
                            a2=RandomNum(100);
                            sign=RandomNum(4);
                            
                            
                                
                                if(choice1[0]==false){
                                    sign=sign%2;
                                }
                                
                                if(choice1[3]==true&&(sign==0||sign==1)){
                                    int ssign=RandomNum(2);
                                    if(ssign==0){
                                        a1=-a1;
                                    }
                                    int ssign2=RandomNum(2);
                                    if(sign==0){
                                        a2=-a2;
                                    }
                                }        
                                if(choice1[2]==true){
                                    a1=a1%10;
                                    a2=a2%10;
                                }
                                if(sign==3&&choice1[4]==false){
                                    a1=a1*a2;    
                                }
                            out.print(a1+"  ");
                            if(sign==0){
                                out.print("  +  ");
                                result=a1+a2;
                            }
                            else if(sign==1){
                                out.print("  -  ");
                                result=a1-a2;
                            }
                            else if(sign==2){
                                out.print("  *  ");
                                result=a1*a2;
                            }
                            else if(sign==3){
                                out.print("  /  ");
                                result=a1/a2;
                            }
                            out.print(a2+"  =  ");
                            %>
                        
                        <form action="main.jsp">
                            请输入答案<input id="answer" type="text" name="answer">
                            
                            <button type="submit" >查看答案</button>
                            
                            </form>    <br>
                            <% }
                        
                        %>
                        
                            
    
        <a class="btn" href="demand.jsp">        
                  返回
        </a>
    </body>
    </html>
    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>答题</title>
    </head>
    <body>
        <% 
        String a;
        a=request.getParameter("demo");
        
        %>
        <script type="text/javascript">
            function judge(){
                try{
                    var x=document.getElementById("answer").value;
                    if(x=="")throw "不能为空";
                    if(isNaN(x))throw "不是数字";
                }
                catch(err)
                {
                var y=document.getElementById("mess");
                y.innerHTML="答案格式不正确!";
                }
            }
            function judge1(a,b){
                if(a==b){
                    document.getElementById("mess2").innerHTML="回答正确";
                }
                else{
                    document.getElementById("mess2").innerHTML="回答错误";
                }    
            }    
            
        </script>
        <p id="mess"></p>
        <p id="mess2"></p>
        <script type="text/javascript">
        
        judge1(3,3);
        </script>
            <div>
                <a class="btn" href="demand.jsp">        
                      返回
                   </a>
            </div>
    </body>
    </html>

    截图:

     

                                周活动总结表

            姓名:苏月                           日期 2016/4/10

    听课

    编写代码

    阅读课本

    准备考试

    日总计

    周日

    周一

    0

    0

    0

    周二

    50

    0

    50

    周三

    100分钟

    70

    20

    90

    周四

    0

    30

    30

    周五

    600

    0

    600

    周六

    400

    0

    400

    周总计

    100分钟

    1120

    50

    1170

      

                                  时间记录日志

              学生:苏月                   日期:2016/4/10

              教师:王建民                 课程:软件工程

    日期

    开始时间

    结束时间

    中断时间

    净时间

    活动

    备注

    C

    U

    4/5

    2:00

    4:00

    20

    100

    编程序

    休息

    4/6

    230

    530

    30

    150

    编程序

    吃饭、休息

    4/8

    1520

    1700

    30

    70

    编程序

    聊程序

    4/9

    400

    2340

    40+10

    410

    写程序写进度条

    吃饭,休息

    4/10

    200

    430

    30

    120

    编程序,写进度条,写总结

    吃饭,看电视,聊天

  • 相关阅读:
    OEP
    壳的执行过程
    JavaScript RSA算法简单实现(转)
    创建根证书及其子证书
    从零开始学习Sencha Touch MVC应用之十四
    javascript base64
    discuz 文档地址
    虚拟机共享数据
    转Javascript到PHP RSA加密通讯的简单实现
    PHP RSA研究
  • 原文地址:https://www.cnblogs.com/syhn/p/5374988.html
Copyright © 2020-2023  润新知