zoukankan      html  css  js  c++  java
  • 四则运算2

    项目计划总结

    任务

    日期

    宿舍编写程序

    20171205

    60

    20171206

    300

    20171207

    90

    时间记录日志

    日期

    开始时间

    结束时间

    中断时间

    净时(分钟)

    活动

    备注

    1205

    16.30

    18.00

    90

    编写四则运算

    19.00

    21.30

    150

    编写四则运算

    1206

    14.30

    17.30

    180

    编写四则运算

    1206

    20.00

    22.00

    120

    编写四则运算

    缺陷记录日志

    日期

    编号

    类型

    引入阶段

    排除阶段

    修复阶段

    修复缺陷

    1205

    1

    编码

    调试

    30m

    描述:jsp文件缺少跳转语句

    package com.jaovo.msg.model;
    
    public class Fraction 
    {
        private int leftnumber;
        private int rightnumber;
        public int getRightnumber() 
        {
            return rightnumber;
        }
        public void setRightnumber(int rightnumber) 
        {
            this.rightnumber = rightnumber;
        }
        public int getLeftnumber() 
        {
            return leftnumber;
        }
        public void setLeftnumber(int leftnumber)
        {
            this.leftnumber = leftnumber;
        }
    }
    package com.jaovo.msg.model;
    public class FractionImpl implements IFraction
    {
        public int getresult(String str) 
        {
            String num[] = str.split(" ");
            int result = 0;
            int left=Integer.parseInt(num[0]);
            int right=Integer.parseInt(num[2]);
            if(num[1].equals("+"))
            {
                result=left+right;
            }
            else if(num[1].equals("-"))
            {
                result =left-right;
            }
            else if(num[1].equals("*"))
            {
                result = left*right;
            }
            else
            {
                result =left/right; 
            }
            return result;
        }
        /*public String GCD(int leftnumber , int rightnumber)
        {
            int one = Math.abs(numerator);
            int two = Math.abs(denominator);
            int min = one>two?two:one;
            int gcd = 1;
            for(int i = min;i>1;i--)
            {
                if((one%i == 0)&&(two%i == 0))
                {
                    gcd = i;
                    break;
                }
            }
            String GCD = Integer.toString(one/gcd)+"/"+Integer.toString(two/gcd);
            if((numerator>0&&denominator<0)||(numerator<0&&denominator>0))
            {
                return ("-"+GCD);
            }
            return GCD;
        }*/
        public String showright(int countright, int number) 
        {
            System.out.println("共答对了"+countright+"道题");
            if(countright >= (int)(number*0.9))
            {
                return ("你真棒!");
            }
            else if(countright >= (int)(number*0.8))
            {
                return ("挺好的!");
            }
            else if(countright >= (int)(number*0.6))
            {
                return ("还可以!");
            }
            else
            {
                return ("再接再厉!");
            }
        }
        public String show()
        {
            Fraction suanshi= new Fraction();
            suanshi.setLeftnumber((int) (Math.random()*100));
            suanshi.setRightnumber((int) (Math.random()*100));
            int operation = (int)(Math.random()*4);
            if(operation == 0)
            {
                return(suanshi.getLeftnumber()+" + "+suanshi.getRightnumber()+" = ");
            }
            else if(operation == 1)
            {
                if(suanshi.getLeftnumber()>suanshi.getRightnumber())
                {
                    return(suanshi.getLeftnumber()+" - "+suanshi.getRightnumber()+" = ");
                }
                else
                {
                    return(suanshi.getRightnumber()+" - "+suanshi.getLeftnumber()+" = ");
                }
                
            }
            else if(operation == 2)
            {
                suanshi.setLeftnumber((int) (Math.random()*10));
                suanshi.setRightnumber((int) (Math.random()*10));
                return(suanshi.getLeftnumber()+" * "+suanshi.getRightnumber()+" = ");
            }
            else
            {
                int suiji=(int) (Math.random()*10);
                suanshi.setRightnumber((int) (Math.random()*9+1));
                suanshi.setLeftnumber(suanshi.getRightnumber()*suiji);
                return(suanshi.getLeftnumber()+" ÷ "+suanshi.getRightnumber()+" = ");
            }
        }
    }
    package com.jaovo.msg.model;
    
    public interface IFraction 
    {
        public int getresult(String str);
        public String show();
        public String showright(int countright, int number);
    }
    <%@ 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>
    <style type = "text/css">
    body{
        font-size:30px;
        color:white;
    }
    </style>
    </head>
    <body background = "../timg2.gif">
        <div align="center">
            <form action="math.jsp" method="get">
                请选择题目数量(1~60): <select name="number" style="font-size:30px">
    
                    <%
                    for(int i = 1;i<=60;i++)
                    {
                        if(i == 30)
                        {
                %>
                    <option value="30" selected>30
                        <%
                            continue;
                        }
                %>
                    
                    <option value=<%=Integer.toString(i) %>><%= Integer.toString(i)%>
                        <%
                    }
                %>
                    
                </select> <br> <input type="submit" value="开始" />
            </form>
        </div>
    </body>
    </html>
    <%@page import="com.jaovo.msg.model.FractionImpl"%>
    <%@ 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>
    <style type = "text/css">
    body
    {
        font-size:20px;
        color:white;
    }
    </style>
    <body background = "../timg3.gif">
    <%
        FractionImpl fractionImpl = new FractionImpl();
        String result[] = request.getParameterValues("result");
        String str = (String)session.getAttribute("right");
        String[] right = str.split(" ");
        int countright = 0;
        for(int i = 0;i<right.length;i++)
        {
            if(right[i].equals(result[i]))
            {
                out.println("第"+(i+1)+"题回答正确!");
                countright++;
            }
            else
            {
                out.println("第"+(i+1)+"题回答错误!正确答案为:"+right[i]);
            }
    %>
            <br>
    <%
        }
    %>
        <%="共答对了"+countright+"道题"%>
        <%=fractionImpl.showright(countright, right.length)%>
    </html>
    <%@page import="com.jaovo.msg.model.FractionImpl"%>
    <%@ 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>
    <title><%=request.getParameter("select") %></title>
    <style type="text/css">
    input{
         60px;
        padding: 5px;
        border:none;
        font-size:20px;
        border-bottom: solid greenyellow 5px;
        text-align:center;
    }
    </style>
    </head>
    <body>
        <%
            long number = Integer.parseInt(request.getParameter("number"));
            FractionImpl fractionImpl = new FractionImpl();
        %>
        <form action = "judge.jsp" method = "get">
        <table cellpadding = "10" border = "0"align = "center">
        <%
            String st = ""; 
            for(int i = 0;i<number/2;i++)
            {
                String str = fractionImpl.show();
                String str1 = fractionImpl.show();
                if(str == null||str1==null)
                {
                    i--;
                    continue;
                }
                st += fractionImpl.getresult(str) + " " + fractionImpl.getresult(str1) + " ";
        %>
            <tr>
                <td><%=str %></td>
                <td><input type = "text" name = "result"/></td>
                <td width = "40"></td>
                <td><%=str1 %></td>
                <td><input type = "text" name = "result"/></td>
            </tr>
        <%
            }
            if(number%2!=0)
            {
        %>
            <tr>
                <td>
                    <%
                        String s = fractionImpl.show();
                        while(s==null)
                        {
                            s = fractionImpl.show();
                        }
                        st += fractionImpl.getresult(s);
                    %>
                    <%=s %>
                </td>
                <td><input type = "text" name = "result"/></td>
            </tr>
            <%
            }
            session.setAttribute("right", st);
            %>
        </table>
        <div align = "center">
            <input type = "submit" value = "提交" />
        </div>
        </form>
    </body>
    </html>

     

  • 相关阅读:
    liststyle
    :nthchild(n)
    织梦CMS首页调用分类信息栏目及列表方法
    []织梦CMS首页调用分类信息栏目及列表方法
    ps快捷键
    系统架构博客,很不错
    google maps api 反向解析 地址 api
    sphinx
    sphinx discuss
    ruby分词
  • 原文地址:https://www.cnblogs.com/cts1234/p/7994740.html
Copyright © 2011-2022 走看看