软件工程结对作业02(借鉴版)

软件工程结对作业02(借鉴版)

在编写程序的时候因为不会将Java程序嵌入进jsp中所以借鉴了一个学姐的程序,下面是学姐的程序。但在对学姐程序就行修改时发现了一些问题:

在Newjsp中能调用html中的题目个数的参数

在Myjsp中不能调用html中的题目个数的参数

其中这个参数timugeshu,是我自己后来添加的,用来改变题目个数的,与Java程序无关,只在jsp文件中作用

源程序:

NewFeil.html

<!DOCTYPE html>
  <html>
    <head>
      <title>四则运算</title>
      <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
      <meta name="keywords" content="keyword1,keyword2,keyword3">
      <meta name="description" content="this is my page">

     <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

   </head>
   <body background="images/A1.jpg">
   <div style="width: 100%; font-family: 微软雅黑; text-align: center">
      <marquee scrollamount=3  style="COLOR=000000 FILTER: shadow(color=000000 );
     FONT-FAMILY: 隶书; FONT-SIZE: 25pt; WIDTH: 100%">
      欢迎来到四则运算乐园</marquee></div>
      <span id="localtime"></span>
    <script type="text/javascript">
        function showLocale(objD) {
            var str, colorhead, colorfoot;
            var yy = objD.getYear();
            if (yy < 1900)
                yy = yy + 1900;
            var MM = objD.getMonth() + 1;
            if (MM < 10)
                MM = ‘0‘ + MM;
            var dd = objD.getDate();
            if (dd < 10)
                dd = ‘0‘ + dd;
            var hh = objD.getHours();
            if (hh < 10)
                hh = ‘0‘ + hh;
            var mm = objD.getMinutes();
            if (mm < 10)
                mm = ‘0‘ + mm;
            var ss = objD.getSeconds();
            if (ss < 10)
                ss = ‘0‘ + ss;
            var ww = objD.getDay();
            if (ww == 0)
                colorhead = "<font color=\"#000000\">";
            if (ww > 0 && ww < 6)
                colorhead = "<font color=\"#000000\">";
            if (ww == 6)
                colorhead = "<font color=\"#000000\">";
            if (ww == 0)
                ww = "星期日";
            if (ww == 1)
                ww = "星期一";
            if (ww == 2)
                ww = "星期二";
            if (ww == 3)
                ww = "星期三";
            if (ww == 4)
                ww = "星期四";
            if (ww == 5)
                ww = "星期五";
            if (ww == 6)
                ww = "星期六";
            colorfoot = "</font>"
            str = colorhead + yy + "-" + MM + "-" + dd + " " + hh + ":" + mm
                    + ":" + ss + "  " + ww + colorfoot;
            return (str);
        }
        function tick() {
            var today;
            today = new Date();
            document.getElementById("localtime").innerHTML = showLocale(today);
            window.setTimeout("tick()", 1000);
        }
        tick();
    </script>
    <br />
    <h1 align="center">题目选择</h1>
   <!-- 传递参数的值给NewFile.jsp处理 -->
   <form action="NewFile.jsp" method="post">
   <!-- 互斥选择,值只能有一个 -->
   <center>
   <br>请选择上限(分数无上下限):
   <select name="TopNumber">
        <option value=20>20</option>
       <option value=30>30</option>
       <option value=50>50</option>
       <option value=80>80</option>
       <option value=100>100</option>
   </select><br>
   <br>请选择下限(分数无上下限):
   <select name="BaseNumber">
       <option value=0>0</option>
       <option value=1>1</option>
       <option value=3>3</option>
       <option value=5>5</option>
       <option value=10>10</option>
       <br>
   </select><br>
   <br>请输入题目个数:<input type="text" name="timugeshu"><br><br>
   <br>请在以下选项中打勾:
   <br>
   <tr>请选择需要的题型是否有乘除法:
   <input type="radio" name="xuanze" value=1>有
   <input type="radio" name="xuanze" value=2>无
   </tr>
   <br>
   <tr>请选择需要的题型是否有余数:
   <input type="radio" name="xuanze1" value=3>有
   <input type="radio" name="xuanze1" value=4>无
   </tr>
   <br>
   <tr>请选择需要的题型是否有括号:
   <input type="radio" name="xuanze2" value=5>有
   <input type="radio" name="xuanze2" value=6>无</tr>
   <br>
   <br>

   <input type="submit" name="submit" value="提交">
   </center>
   </form>
   </body>
 </html>

NewFeil.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
     pageEncoding="utf-8"%>
  <%@ page import="szys.*"%>
  <%
  String path = request.getContextPath();
  String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
  %>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
   <head>
     <base href="<%=basePath%>">
     <title>四则运算</title>
     <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
          <meta http-equiv="pragma" content="no-cache">
     <meta http-equiv="cache-control" content="no-cache">
     <meta http-equiv="expires" content="0">
     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
     <meta http-equiv="description" content="This is my page">
     <!--
     <link rel="stylesheet" type="text/css" href="styles.css">
     -->
   </head>
   <body background="images/A2.jpg">
    <%
    int timugeshu=Integer.parseInt((String)request.getParameter("timugeshu"));
    String[] s=new String[timugeshu];
    float k[]=new float[timugeshu];
    math a=new math();
    request.setCharacterEncoding("UTF-8");
    String xuanze = request.getParameter("xuanze");
    String xuanze1 = request.getParameter("xuanze1");
    String xuanze2 = request.getParameter("xuanze2");
    String TopNumber,BaseNumber;
    TopNumber=request.getParameter("TopNumber");
    BaseNumber=request.getParameter("BaseNumber");
    a.SetValue(a.StrToNum(TopNumber),a.StrToNum(BaseNumber));
    if(xuanze!=null&&xuanze1!=null&&xuanze2!=null){
    if(xuanze.equals("1"))
    {
          a.SetValue1(1);
    }
    if(xuanze1.equals("3"))
    {
           a.SetValue2(1);
    }
    if(xuanze2.equals("5"))
    {
          a.SetValue3(1);
    }
 }
     %>
    <form action="Myjsp.jsp" method="post">
    <center>
    <%
      a.main(timugeshu);
      float temp;
      String[] se=new String[timugeshu];
      for(int i=0;i<timugeshu;i++){
      s[i]=a.cs(i);
      se[i]="name";
      se[i]=se[i]+i;
      k[i]=a.css(i);
      out.print("<tr>"+s[i]+"</tr>");
      out.println("<br>");

    %>
    <input type="text" name=<%=se[i] %>><br>
    <%
        }
         session.setAttribute( "v1",s);
         session.setAttribute( "v2",k);
     %>
     <br><input type="submit" name="submit" value="提交">
     <%    %>
      </center>
   </form>

   </body>
 </html>

MyFeil.jsp

<%@ page language="java" import="java.util.*" pageEncoding="gb2312" contentType="text/html; charset=gb2312"%>
<%@ page import="szys.*"%>
<%String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
     <base href="<%=basePath%>">
     <title>答题情况</title>
     <meta http-equiv="pragma" content="no-cache">
     <meta http-equiv="cache-control" content="no-cache">
     <meta http-equiv="expires" content="0">
     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
     <meta http-equiv="description" content="This is my page">
     <!--
     <link rel="stylesheet" type="text/css" href="styles.css">
     -->
   </head>

  <body background="images/A3.jpg">
   <% request.setCharacterEncoding("UTF-8");%>
   <center>
   <%
     int timugeshu=Integer.parseInt((String)request.getParameter("timugeshu"));
     String[] name=new String[timugeshu];
     String[] sum=new String[timugeshu];
     math a=new math();
     float sum1[]=new float[timugeshu];
     int right=0;
     String[] s= (String[])session.getAttribute("v1");
     float[] k=(float[])session.getAttribute("v2");

     for(int i=0;i<timugeshu;i++)
         sum1[i]=0;
     for(int i=0;i<timugeshu;i++){
         name[i]="name";
         name[i]=name[i]+i;
         sum[i]=request.getParameter(name[i]);
         out.print(s[i]);
         out.print("<tr>"+sum[i]+"</tr>");
         if(sum[i]=="")
            out.print("未回答!");
         else{
             if(((int)(k[i]*100))%100!=0)
                sum1[i]=a.StrToFloat1(sum[i]);
             else
                sum1[i]=a.StrToFloat(sum[i]);
             if(Math.abs(sum1[i]*100-k[i]*100)<4){
                out.print(" 回答正确!");
                right++;
             }
             else
                out.print(" 回答错误,正确答案是: "+k[i]);
         }   

          out.println("<br>");
     }
     out.print("总共做对 "+right+" 题,正确率为:"+(right/timugeshu)*100+" %");
   %><br>
    <input type="button" value="返回首页" onClick="window.location.href=‘MyHtml.html‘">
    <input type="button" value="关闭" onClick="window.close();">
     </center>
   </body>
 </html>

Math.java

package math;
   import java.util.*;
   public class math{
           static int MAX=100;
           static String formula = "";         //当前算式
           static String[] buffer = new String[MAX];     //缓冲区数组
           static int TopNumber;          //上限
           static int BaseNumber;         //下限
           static int chengchu;      //是否有乘除
          static int Amount;             //操作数的个数
          static int BracketNum;         //括号个数
          static int[] LBraket = new int[2];         //左括号的位置
          static int[] RBraket = new int[2];         //右括号的位置
          static int IsNeg;              //是否有负数
          static int IsRem;              //是否有余数
          static int IsBra;              //是否有括号
          static int IsRep;              //是否重复
          static float[] Result= new float[MAX];      //正确结果数组
          static char lastOp;            //记录上个运算符是否为除号

          //优先级数组
          static char[][] prior = {
              { ‘>‘, ‘>‘, ‘<‘, ‘<‘, ‘<‘, ‘>‘, ‘>‘ },
              { ‘>‘, ‘>‘, ‘<‘, ‘<‘, ‘<‘, ‘>‘, ‘>‘ },
              { ‘>‘, ‘>‘, ‘>‘, ‘>‘, ‘<‘, ‘>‘, ‘>‘ },
              { ‘>‘, ‘>‘, ‘>‘, ‘>‘, ‘<‘, ‘>‘, ‘>‘ },
              { ‘<‘, ‘<‘, ‘<‘, ‘<‘, ‘<‘, ‘=‘, ‘ ‘ },
              { ‘>‘, ‘>‘, ‘>‘, ‘>‘, ‘ ‘, ‘>‘, ‘>‘ },
              { ‘<‘, ‘<‘, ‘<‘, ‘<‘, ‘<‘, ‘ ‘, ‘=‘ }
          };

          //将操作符转化为优先级数组的下标
          static int Change(String Oper)
          {
              switch (Oper.charAt(0))
              {
                  case ‘+‘: return 0;
                  case ‘-‘: return 1;
                  case ‘*‘: return 2;
                  case ‘/‘: return 3;
                  case ‘(‘: return 4;
                  case ‘)‘: return 5;
                  case ‘=‘: return 6;
                  default:  return 6;
              }
          }
          static int Change(char Oper)
          {
              switch (Oper)
              {
                  case ‘+‘: return 0;
                  case ‘-‘: return 1;
                  case ‘*‘: return 2;
                  case ‘/‘: return 3;
                  case ‘(‘: return 4;
                  case ‘)‘: return 5;
                  case ‘=‘: return 6;
                  default:  return 6;
              }
          }
          static //返回优先级的大小
          char Precede(char Oper, char ch)
          {
              return prior[Change(Oper)][Change(ch)];
          }

          //计算两个数的结果
          static float Operate(float first, char oper1, float second)
          {
              switch (oper1)
              {
              case ‘+‘:
              {
                          return (first + second);
              }
              case ‘-‘:
              {
                  if (first-second<0)
                  {
                      IsRep = 1;
                      return 0;
                  }
                          return (first - second);
              }
              case ‘*‘:
              {
                          return (first * second);
              }
              case ‘/‘:
              {
                          if (second == 0)
                          {
                              IsRep = 1;
                              return 0;
                          }
                          return (first / second);
              }
              default:  return 0;
              }
         }

         //数字的个数
         static void NumberAmount()
         {
             Amount = 2 + (int)((Math.random())*3);
         }

         //加左括号   随机选择在第几个数字前面加括号
         static void AddLbracket(){
             for (int j = 0; j < 2; j++)
                 LBraket[j] = 0;
             if (Amount == 2)
             {
                 BracketNum = 0;
             }
             if (Amount == 3){
                 BracketNum = (int)((Math.random())*2);
             }
             if (Amount > 3)
             {
                 BracketNum = (int)((Math.random())*3);
             }
             for (int i = 0; i < BracketNum; i++){
                 LBraket[i] = 1 + (int)((Math.random())*(Amount - 2));
             }
         }
         //加右括号
         static void AddRbracket(){
             for (int j = 0; j < 2; j++)
                 RBraket[j] = 0;
             int choose;
             int trance;
             if (BracketNum == 1){
                 RBraket[0] = LBraket[0] + 1 +(int)((Math.random())* (Amount - LBraket[0]));
             }
             if (BracketNum == 2)

             {
                 //把最左边的左括号放在第一个数组中
                 if (LBraket[0] < LBraket[1])
                 {
                     trance = LBraket[0];
                     LBraket[0] = LBraket[1];
                     LBraket[1] = trance;
                 }
                 //当两个左括号之间相差有点远时有2中右括号添加方法
                 if (LBraket[0] - LBraket[1]>2){
                     choose = (int)((Math.random())*2);
                     if (choose == 0){
                         RBraket[0] = LBraket[0] + 1 + (int)((Math.random())*(Amount - LBraket[0]));
                         RBraket[1] = LBraket[0] + 1 + (int)((Math.random())*(Amount - LBraket[0]));
                     }
                     if (choose == 1)
                     {
                         RBraket[0] = LBraket[0] + 1 + (int)((Math.random())*(Amount - LBraket[0]));
                         RBraket[1] = LBraket[1] + 1 + (int)((Math.random())*(LBraket[0] - 2));
                     }
                 }
                 else
                 {
                     RBraket[0] = LBraket[0] + 1 + (int)((Math.random())*(Amount - LBraket[0]));
                     RBraket[1] = LBraket[0] + 1 + (int)((Math.random())*(Amount - LBraket[0]));
                     if (LBraket[0] == LBraket[1] && RBraket[0] == RBraket[1]){
                         LBraket[0] = LBraket[1] = 0;
                         RBraket[0] = RBraket[1] = 0;
                         BracketNum = 0;
                     }
                     if (LBraket[1] == 1 && (RBraket[0] == Amount || RBraket[1] == Amount))
                     {
                         LBraket[0] = LBraket[1] = 0;
                         RBraket[0] = RBraket[1] = 0;
                         BracketNum = 0;
                     }

                 }
             }
         }

         //随机产生最简真分数
         static void Score(){
             int Left, Right;
             Left = BaseNumber + (int)((Math.random())*(TopNumber - BaseNumber + 1));
             Right = BaseNumber + (int)((Math.random())*(TopNumber - BaseNumber + 1));
             while (Left >= Right || Left == 0)
             {
                 Left = BaseNumber + (int)((Math.random())*(TopNumber - BaseNumber + 1));
                 Right = BaseNumber + (int)((Math.random())*(TopNumber - BaseNumber + 1));
             }
             int max = 1;
             //求最大公约数
             for (int i = 2; i <= Left; i++)
             {
                 if (Left%i == 0 && Right%i == 0)
                 {
                     max = i;
                 }
             }
             if (max > 1)
             {
                 Left /= max;
                 Right /= max;
             }
             formula += "(" + Left + "/" + Right + ")";
         }

         //随机生成操作符
         static void Operater()
         {
             int choose;
             char op=‘+‘;
             if (chengchu== 1)
                 choose = 1 + (int)((Math.random())* 4);
             else
                 choose = 1 + (int)((Math.random())*2);

             switch (choose)
             {
                 case 1:{op = ‘+‘; lastOp = ‘+‘; break; }
                 case 2:{op = ‘-‘;  lastOp = ‘-‘; break; }
                 case 3:{op = ‘*‘;  lastOp = ‘*‘; break; }
                 case 4:
                 {
                           //防止连续除法产生运算误区
                           op = ‘/‘;
                           if (lastOp == ‘/‘)
                               IsRep = 1;
                           else
                               lastOp = ‘/‘;
                           break;
                 }
             }
             formula += op;
         }

         //随机生成整数
         static void Integer(){
             int num;
             num = BaseNumber + (int)((Math.random())*(TopNumber - BaseNumber + 1));
             formula += num;
         }
         //创建算式
         static void CreateNumber(){
             for (int k = 1; k <= Amount; k++)
             {

                 for (int i = 0; i < 2; i++){
                     if (LBraket[i] == k)
                         formula += "(";
                 }
                  int cho;
                 cho = (int)((Math.random())*2);
                 if (cho == 0)
                 {
                     Integer();
                 }
                 else
                     Score();
                 for (int j = 0; j < 2; j++){
                     if ((RBraket[j] == k) && RBraket[j] != 0)
                         formula += ")";
                 }
                 if (k == Amount)
                     formula += "=";
                 else
                  Operater();
           }
         }
         //检查是否重复及判断括号是否添加正确
         static int Repeat(int time){
             buffer[time] = formula;
             int juege = 0;
             int trance;
             for (int i = 0; i < time; i++)
             {
                if (buffer[i] == buffer[time])
                 {
                     juege = 1;
                     break;
                 }
             }
             if (IsBra != 1)
             {
                if (BracketNum == 1)
                 {
                     if (LBraket[0] == 1 && RBraket[0] == Amount)
                         juege = 1;
                                      }
                 if (BracketNum == 2)
                 {
                     if (RBraket[0] < RBraket[1])
                     {
                         trance = RBraket[0];
                         RBraket[0] = RBraket[1];
                         RBraket[1] = trance;
                     }
                     if (LBraket[1] == 1 && RBraket[0] == Amount&&LBraket[0] < RBraket[1])
                         juege = 1;
                 }
             }
             return juege;
         }
         static float EvaluateExpression(){
             float[] OPND=new float[MAX];
             char[] OPTR =new char[MAX];
             int Ntop=0;
             int Ctop=0;
             OPTR[Ctop++]=‘=‘;
             int count = 0;
             float Num = 0, first, second;
             char oper1;
             char bracket1;
             while (true)
             {
                Num = 0;
                 //读取数字
                 while (formula.charAt(count) >= ‘0‘&&formula.charAt(count) <= ‘9‘)
                 {
                     if (formula.charAt(count) == ‘0‘)
                     {
                         if (count == 0)
                             OPND[Ntop++]=0;
                         if (count != 0 && !(formula.charAt(count-1) >= ‘0‘&&formula.charAt(count-1) <= ‘9‘))
                             OPND[Ntop++]=0;
                     }
                     Num = Num * 10;
                     Num = Num + formula.charAt(count) - 48;
                                          count++;
                 }
                 if (Num > 0)
                 {
                     OPND[Ntop++]=Num;
                 }
                 if (formula.charAt(count) == ‘=‘&&OPTR[Ctop-1] == ‘=‘)
                 {
                     break;
                 }
                 //判断运算符优先级
                 switch (Precede(OPTR[Ctop-1], formula.charAt(count)))
                 {
                     case ‘<‘:
                     {
                        OPTR[Ctop++]=formula.charAt(count);
                             count++;
                             break;
                     }
                     case ‘>‘:
                     {
                         oper1=OPTR[--Ctop];
                         second=OPND[--Ntop];
                         first=OPND[--Ntop];
                         OPND[Ntop++]=Operate(first, oper1, second);
                             break;
                     }
                     case ‘=‘:
                     {
                         bracket1=OPTR[--Ctop];
                                 count++;
                     }
                 }
             }
             return OPND[Ntop-1];
         }

         public static void SetValue(int IsMulDlvExist1,int IsRem1,int IsBra1,int TopNumber1,int BaseNumber1)
         {
             chengchu=0;
             BaseNumber=0;
             TopNumber=10;
             IsNeg=0;
             IsRem=0;
             IsBra=1;

             chengchu=IsMulDlvExist1;
             TopNumber=TopNumber1;
             BaseNumber=BaseNumber1;
             IsRem=IsRem1;
             IsBra=IsBra1;
         }
         public static void SetValue1(int IMDE)
         {
             chengchu=IMDE;
         }
         public static void SetValue2(int Rem)
         {
             IsRem=Rem;
         }
         public static void SetValue3(int Bra)
         {
             IsBra=Bra;
         }
         public static void SetValue(int TopNumber1,int BaseNumber1){
             chengchu=0;
             BaseNumber=0;
             TopNumber=10;
             IsNeg=0;
             IsRem=0;
             IsBra=1;
             TopNumber=TopNumber1;
             BaseNumber=BaseNumber1;

         }

         public static int StrToNum(String x)
         {
               int num=0;
                for(int i=0;i<x.length();i++)
                {
                        num=num*10+x.charAt(i)-48;
                }
                return num;
         }
         public static float StrToFloat(String x)
         {
             float num=0;
             int doat=0;
             int mi=-1;
             for(int i=0;i<x.length();i++)
             {
                 if(x.charAt(i)==‘.‘)
                 {
                     doat=1;
                     continue;
                 }
                 if(doat==1)
                 {
                     num=(float) (num+(x.charAt(i)-48)*Math.pow(10,mi));
                     mi--;
                 }else{
                     num=num*10+x.charAt(i)-48;
                 }
             }
             return num;

         }
         public static float StrToFloat1(String x)
         {
             float first=0;
             float second=0;
             int point=0;
             for(int i=0;i<x.length();i++)
             {
                 if(x.charAt(i)==‘/‘)
                 {
                     point=1;
                     continue;
                 }
                 if(point==1)
                 {
                     second=second*10+x.charAt(i)-48;
                 }else
                 {
                     first=first*10+x.charAt(i)-48;
                 }
             }
             return (first/second);
         }
         static int ma()
         {
             int OutChoose = 0;
             int truenum = 0;
             int choose;
             boolean flag = true;
             int range = 0;
             for (int i = 0; i < 30; i++)
             {
                 lastOp = ‘+‘;
                 IsRep = 0;
                NumberAmount();
                 if (IsBra == 0)
                 {
                     AddLbracket();
                     AddRbracket();
                 }
                 CreateNumber();
                 Result[i] = EvaluateExpression();
                 while (Repeat(i) == 1 || IsRep == 1 || (IsNeg == 1 && (Result[i] < 0 || Result[i] == -0)) || (IsRem == 1 && ((int)(Result[i]*10000))%10000!=0))
                 {

                     IsRep = 0;
                     lastOp = ‘+‘;
                     formula="";
                     NumberAmount();
                     if (IsBra == 0)
                     {
                         AddLbracket();
                         AddRbracket();
                     }
                     CreateNumber();
                     Result[i] = EvaluateExpression();
                 }
                 buffer[i]=formula;
                formula="";
             }

             return 0;
         }
         public static float css(int number){
             return Result[number];
        }
         public static String cs(int number){
             return buffer[number];
         }
     public static void main()
     {
         int a;
         a=ma();
         for (int i = 0; i < 30; i++)
         {
             System.out.println(buffer[i]+Result[i]);
         }

     }
 }
时间: 2024-10-22 04:11:07

软件工程结对作业02(借鉴版)的相关文章

软件工程结对作业02(原创版)

一.设计思路 1.在HTML文件中写题目选择项 2.输入一个数控制题目个数 3.输入一个数控制取值范围(小于100) 4.输入一个数控制参数个数 5.选择是否有乘除法数 6.在有乘除法时,选择是否有余法 7.选择是否有括号 8.点击提交按钮,通过一个链接进入jsp文件,并且用户在HTML输入的参数传到jsp 页面 9.调用java函数,输出题目 10.点击开始答题之后,进入下一个jsp页面,用户答题并显示用户答题情况 二.源代码: HTML文件 <!DOCTYPE html PUBLIC "

软件工程结对作业02

import java.util.Scanner; class Fraction//分数 { public int numerator;//分子 public int denominator;//分母 public void creatFraction() { //--生成值并化简-- boolean bool=false; while(bool==false) { int up=(int)(1+Math.random()*10); int down=(int)(1+Math.random()*

软件工程结对作业 四则运算界面设计

软件工程结对作业 四则运算界面设计 康鑫  PB16060203 娄雨禛  PB16060356 一.项目分析 二.进度规划与完成情况 三.主要函数 四.简单的数据测试 五.编程困惑与心得 原文地址:https://www.cnblogs.com/RainLou/p/8735480.html

软件工程个人作业02(四则运算)

四则运算作业02 import javax.swing.JOptionPane; import java.util.Random; import java.util.Scanner; public class Arithmetic { public static void main(String[] args) { // TODO 自动生成的方法存根 int c;//选择 int c1,c4,c5,c6,c7,c8; int a,b,d1;//二位数运算 int c2,c3; int e=0;/

软件工程结对作业01--四则运算Web版

一.设计思想: 首先,写出一个菜单界面,有两个选项一个是分数,一个是整数.而这两个标签后面则是转向其更详细的菜单,题目数量,有无括号,运算的项数等等详细功能,再点击这两个按钮之后,就会跳转过去.当选择整数运算时,显示出需要的菜单,输入完要求之后,跳转到生成算式的JSP文件,在此文件中首先是用request方法来获取上个页面中你所需要的功能,然后再强制类型转化来为下面使用,通过随机数生成,分别生成参与运算的数和符号,0代表加法1代表减法3代表乘法4代表除法.选择有负数和有余数式子生成,选择没有负数

软件工程结对作业01

一.题目: 结对项目开发-四则运算四 把程序变成一个网页程序,用户通过设定参数,就可以得到各种题目,并可实现在线答题并评判. 注:这是一个两人结对开发的项目,开发人员:曾凯    刘雨鑫 二.程序设计思想: (1)功能分析: 1.这是一个可以在线答题的web版四则运算程序,用户可以通过设点一些参数来生成题目,然后回答这些题目,提交后程序检查回答的正确性,然后将题目的回答情况通过页面显示的方式反馈给用户. 2.由于参数设置导致交互不太方便,用户需要考虑参数如何搭配,由此实现按照年级答题,用户只需要

软件工程概论作业02

这周,我们上了软件工程概论第三节课,终于体会到的程序员的不易,作业一次比一次难,老师提出的要求越来越多,就像未来的客户一样,要求永远无止境. 这次还在上次的要求上提出了新的要求,要求可选择整数还是分数,可指定范围,不可重复. 可怜的二柱子同学,老师又对他的自动出题系统提出了新的要求: 可以控制下列参数: 是否有乘除法: 是否有括号(最多可以支持十个数参与计算): 数值范围: 加减有无负数: 除法有无余数! 日期 开始时间 结束时间 中断时间 净时间 活动 备注 C U 3/10 14:00 16

软件工程结队作业02

设计思想:    使用jsp实现java代码与网页的连接,利用数组实现数据的传输.Session对象页面的跳转功能. 源代码: 运行结果截图: 编程总结: 对jsp和session的使用不熟悉,不知道如何将java代码插入到网页程序中,所以参考了网上代码进行编写. 周活动总结表 姓名:杜若憧                            日期 2016/4/8 听课 编写代码 阅读课本 准备考试 日总计 周日 周一 50 50 周二 100 60 160 周三 22 22 周四 30 3

软件工程个人作业02(四则运算2)

题目要求: 是否有乘除法:  是否有括号(最多可以支持十个数参与计算):  数值范围:  加减有无负数:  除法有无余数!    四则运算2的设计思想:因为题目要求可以选择是否有除法,是否有括号,加减有无负数,除法有无余数.所以这里考虑用if~~else语句来进行选择.目前程序无法完成生成题目是否有括号的要求.    源程序代码: import java.util.Random; import java.util.Scanner; public class sizeyunsuan2 { /*是否