Web項目下 Tomcat服務器的路徑 /WebContant/ 目錄下

SE2_2.jsp

<%@ 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 class="no-js">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge; charset=UTF-8">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" type="image/png"
href="https://lh6.googleusercontent.com/-xtIe5pwl_0Y/VQk1jMCNZZI/AAAAAAAAADo/Hc_21K6mVr8/s578-no/%E7%90%AA%E9%9C%B2%E8%AF%BA%E5%A4%B4%E5%83%8F.jpg">
<title>小學四則運算</title>
<link rel="stylesheet"
href="http://cdn.amazeui.org/amazeui/2.2.1/css/amazeui.min.css" />
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript"
src="http://cdn.amazeui.org/amazeui/2.2.1/js/amazeui.min.js"></script> <!-- cookie 用戶名 -->
<script type="text/javascript">
function getCookie(c_name) {
if (document.cookie.length > 0) {
c_start = document.cookie.indexOf(c_name + "=")
if (c_start != -1) {
c_start = c_start + c_name.length + 1
c_end = document.cookie.indexOf(";", c_start)
if (c_end == -1)
c_end = document.cookie.length
return unescape(document.cookie.substring(c_start, c_end))
}
}
return ""
} function setCookie(c_name, value, expiredays) {
var exdate = new Date()
exdate.setDate(exdate.getDate() + expiredays)
document.cookie = c_name
+ "="
+ escape(value)
+ ((expiredays == null) ? "" : "; expires="
+ exdate.toGMTString())
} function checkCookie() {
username = getCookie('username')
if (username != null && username != "") {
alert('歡迎你的到來,' + username + '!')
} else {
username = prompt('請輸入用戶名:', "")
if (username != null && username != "") {
setCookie('username', username, 3)
}
}
}
</script>
</head>
<body class="am-g" style="text-align: center" onload="checkCookie()">
<h1 class="am-u-lg-6 am-u-md-8 am-u-sm-centered">小學四則運算系統 ver1.0</h1>
<!--設置 背景色 功能-->
<h2 class="am-u-lg-6 am-u-md-8 am-u-sm-centered">設置背景顏色</h2>
<div class="am-u-lg-6 am-u-md-8 am-u-sm-centered">
<div id="color" class="am-btn-group doc-js-btn-1" data-am-button>
<label class="am-btn am-btn-default"> <input type="radio"
name="options" value="white" id="option1"> 白色
</label> <label class="am-btn am-btn-primary"> <input type="radio"
name="options" value="#0e90d2" id="option2"> 藍色
</label> <label class="am-btn am-btn-secondary"> <input type="radio"
name="options" value="#3bb4f2" id="option3"> 淡藍色
</label> <label class="am-btn am-btn-success"> <input type="radio"
name="options" value="#5eb95e" id="option4"> 綠色
</label> <label class="am-btn am-btn-warning"> <input type="radio"
name="options" value="#f37b1d" id="option5"> 橙色
</label> <label class="am-btn am-btn-danger"> <input type="radio"
name="options" value="#dd514c" id="option6"> 紅色
</label>
</div>
<hr data-am-widget="divider" style=""
class="am-divider am-divider-default" />
</div>
<script type="text/javascript">
// 获取选中的值
$(document).ready(
function() {
$(function() {
var $radios = $('[name="options"]');
$radios.on('change', function() {
console.log('单选框当前选中的是:', $radios
.filter(':checked').val());
});
}); $("#color").click(
function() {
$("body").css(
"background-color",
$('input[name="options"]').filter(
':checked').val());
});
});
</script> <!-- 設置 題目 數量 -->
<form name="form" class="am-form-inline" role="form" action="SE2_1.jsp"
method="post">
<div class="am-form-group">
<span>請輸入題目數量:</span> <input name="number" type="number" min="1"
max="5" class="am-form-field" placeholder="題數">
</div>
<button type="submit" class="am-btn am-btn-default">確定</button>
</form>
</body>
</html>

SE2_1.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.SE2.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html class="no-js">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge; charset=UTF-8">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" type="image/png"
href="https://lh6.googleusercontent.com/-xtIe5pwl_0Y/VQk1jMCNZZI/AAAAAAAAADo/Hc_21K6mVr8/s578-no/%E7%90%AA%E9%9C%B2%E8%AF%BA%E5%A4%B4%E5%83%8F.jpg">
<title>小學四則運算</title>
<link rel="stylesheet"
href="http://cdn.amazeui.org/amazeui/2.2.1/css/amazeui.min.css" />
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript"
src="http://cdn.amazeui.org/amazeui/2.2.1/js/amazeui.min.js"></script> <!-- 延時 計時 功能 -->
<script type="text/javascript">
var c = 120
var t
function timedCount() {
document.getElementById('txt').value = c
c = c - 1
if (c == 0) {
document.getElementById('txt').value = c
clearTimeout(t)
alert('120秒到了!')
} else
t = setTimeout("timedCount()", 1000)
}
function gettime(){
document.getElementById('time').value = 120-c;
}
</script>
</head>
<body class="am-g" style="text-align: center" onload="timedCount()">
<h1 class="am-u-lg-6 am-u-md-8 am-u-sm-centered">小學四則運算系統 ver1.0</h1>
<!--設置 背景色 功能-->
<h2 class="am-u-lg-6 am-u-md-8 am-u-sm-centered">設置背景顏色</h2>
<div class="am-u-lg-6 am-u-md-8 am-u-sm-centered">
<div id="color" class="am-btn-group doc-js-btn-1" data-am-button>
<label class="am-btn am-btn-default"> <input type="radio"
name="options" value="white" id="option1"> 白色
</label> <label class="am-btn am-btn-primary"> <input type="radio"
name="options" value="#0e90d2" id="option2"> 藍色
</label> <label class="am-btn am-btn-secondary"> <input type="radio"
name="options" value="#3bb4f2" id="option3"> 淡藍色
</label> <label class="am-btn am-btn-success"> <input type="radio"
name="options" value="#5eb95e" id="option4"> 綠色
</label> <label class="am-btn am-btn-warning"> <input type="radio"
name="options" value="#f37b1d" id="option5"> 橙色
</label> <label class="am-btn am-btn-danger"> <input type="radio"
name="options" value="#dd514c" id="option6"> 紅色
</label>
</div>
<hr data-am-widget="divider" style=""
class="am-divider am-divider-default" />
</div>
<script type="text/javascript">
// 获取选中的值
$(document).ready(
function() {
$(function() {
var $radios = $('[name="options"]');
$radios.on('change', function() {
console.log('单选框当前选中的是:', $radios
.filter(':checked').val());
});
}); $("#color").click(
function() {
$("body").css(
"background-color",
$('input[name="options"]').filter(
':checked').val());
});
});
</script> <!-- javabean -->
<jsp:useBean id="SE2_1" class="com.SE2.SE2_1" scope="request" /> <!-- 延時 功能-->
<div id="count">
<span>算題時間倒計時:</span> <input id="txt" type="button"
class="am-btn am-btn-danger" disabled="disabled" />
</div>
<hr data-am-widget="divider" style=""
class="am-divider am-divider-default" />
<%
String number=request.getParameter("number");
String [] num={"①","②","③","④","⑤"};
int inumber=Integer.parseInt(number);
double [][] Answer=new double[inumber][2];
String [] str=new String[inumber];
String [] s=new String[inumber];
String [] an=new String[inumber];
String [] t=new String[inumber];
for(int i=0;i<inumber;i++){
s[i]="Answer"+String.valueOf(i);
an[i]="an"+String.valueOf(i);
t[i]="title"+String.valueOf(i);
}
//out.print(number+"<br />");
for(int i=0;i<inumber;i++){
SE2_1.GA();
Answer[i][0]=SE2_1.getdaan9number();
Answer[i][1]=SE2_1.getdaan12();
str[i]=SE2_1.getshizi9();
//out.print(str[i]);
//out.print(Answer[i][0]+"四捨五入答案"+Answer[i][1]+"<br />");
}
%>
<div class="am-u-lg-6 am-u-md-8 am-u-sm-centered">
<form class="am-form am-form-horizontal" action="SE2_3.jsp" method="post" > <% for(int i=0;i<inumber;i++){%>
<div class="am-form-group">
<label class="am-u-sm-1 am-form-label"><%=num[i] %></label><label for="doc-ipt-3" class="am-u-sm-8 am-form-label"><%out.print(str[i]); %></label>
<div class="am-u-sm-3">
<input type="text" name="<%=an[i] %>" id="doc-ipt-3" placeholder="输入答案">
</div>
</div>
<div class="am-form-group">
<div class="am-u-sm-offset-2 am-u-sm-10"></div>
</div>
<%} %>
<div class="am-form-group">
<div class="am-u-sm-10 am-u-sm-offset-2">
<button type="submit" class="am-btn am-btn-primary" onclick="gettime()">提交</button>
</div>
</div>
<input type="hidden" name="inumber" value="<%=inumber%>"/>
<%
for(int i=0;i<inumber;i++){
%>
<input type="hidden" name="<%=t[i] %>" value="<%=str[i] %>" />
<input type="hidden" name="<%=s[i] %>" value="<%=Answer[i][0] %>"/>
<%} %>
<input id="time" type="hidden" name="time" value="" />
</form>
</div>
</body>
</html>

SE2_3.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.SE2.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html class="no-js">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge; charset=UTF-8">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" type="image/png"
href="https://lh6.googleusercontent.com/-xtIe5pwl_0Y/VQk1jMCNZZI/AAAAAAAAADo/Hc_21K6mVr8/s578-no/%E7%90%AA%E9%9C%B2%E8%AF%BA%E5%A4%B4%E5%83%8F.jpg">
<title>小學四則運算</title>
<link rel="stylesheet"
href="http://cdn.amazeui.org/amazeui/2.2.1/css/amazeui.min.css" />
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript"
src="http://cdn.amazeui.org/amazeui/2.2.1/js/amazeui.min.js"></script>
<style type="text/css">
th{
text-align:center
}
</style>
</head>
<body class="am-g" style="text-align: center">
<h1 class="am-u-lg-6 am-u-md-8 am-u-sm-centered">小學四則運算系統 ver1.0</h1>
<!--設置 背景色 功能-->
<h2 class="am-u-lg-6 am-u-md-8 am-u-sm-centered">設置背景顏色</h2>
<div class="am-u-lg-6 am-u-md-8 am-u-sm-centered">
<div id="color" class="am-btn-group doc-js-btn-1" data-am-button>
<label class="am-btn am-btn-default"> <input type="radio"
name="options" value="white" id="option1"> 白色
</label> <label class="am-btn am-btn-primary"> <input type="radio"
name="options" value="#0e90d2" id="option2"> 藍色
</label> <label class="am-btn am-btn-secondary"> <input type="radio"
name="options" value="#3bb4f2" id="option3"> 淡藍色
</label> <label class="am-btn am-btn-success"> <input type="radio"
name="options" value="#5eb95e" id="option4"> 綠色
</label> <label class="am-btn am-btn-warning"> <input type="radio"
name="options" value="#f37b1d" id="option5"> 橙色
</label> <label class="am-btn am-btn-danger"> <input type="radio"
name="options" value="#dd514c" id="option6"> 紅色
</label>
</div>
<hr data-am-widget="divider" style=""
class="am-divider am-divider-default" />
</div>
<script type="text/javascript">
// 获取选中的值
$(document).ready(
function() {
$(function() {
var $radios = $('[name="options"]');
$radios.on('change', function() {
console.log('单选框当前选中的是:', $radios
.filter(':checked').val());
});
}); $("#color").click(
function() {
$("body").css(
"background-color",
$('input[name="options"]').filter(
':checked').val());
});
});
</script> <!-- javabean -->
<jsp:useBean id="SE2_1" class="com.SE2.SE2_1" scope="request" />
<%
String inumber=request.getParameter("inumber");
String time=request.getParameter("time");
int number=Integer.parseInt(inumber);
String []Answer=new String[number];
String []input=new String[number];
String []title=new String[number];
for(int i=0;i<Answer.length;i++){
title[i]=request.getParameter("title"+i);
input[i]=request.getParameter("an"+i);
Answer[i]=request.getParameter("Answer"+i);
SE2_1.setshuru(input[i]);
SE2_1.Input(input[i]);
}
int zhengque=SE2_1.panduan(input,Answer);
int cuowu=number-zhengque;
double rate=(double)zhengque/number*100;
%>
<div class="am-u-lg-6 am-u-md-8 am-u-sm-centered">
<h1 class="am-u-lg-6 am-u-md-8 am-u-sm-centered">對照答案</h1>
<table
class="am-table am-table-bordered am-table-striped am-table-hover">
<thead>
<tr>
<th>題目</th>
<th>你的輸入</th>
<th>參考答案</th>
</tr>
</thead>
<tbody>
<%for(int i=0;i<number;i++){ %>
<tr>
<td><%=title[i] %></td>
<td><%=input[i] %></td>
<td><%=Answer[i] %><br />四捨五入後:<%=SE2_1.strto12(Answer[i]) %></td>
</tr>
<%} %>
</tbody>
</table>
</div>
<div class="am-u-lg-6 am-u-md-8 am-u-sm-centered">
<h1 class="am-u-lg-6 am-u-md-8 am-u-sm-centered">分數統計</h1>
<table
class="am-table am-table-bordered am-table-striped am-table-hover">
<tbody>
<tr>
<td>總共</td>
<td><%=inumber %>題</td>
</tr>
<tr>
<td>正確情況</td>
<td>答對<%=zhengque %>題,答錯<%=cuowu %>題</td>
</tr>
<tr>
<td>正確率</td>
<td><%=rate%>%</td>
</tr>
<tr>
<td>用時</td>
<td><%=time %>秒</td>
</tr>
</tbody>
</table>
</div>
<button type="button" class="am-btn am-btn-default"><a class="am-btn am-btn-link" href="SE2_2.jsp">繼續答題</a></button>
</body>
</html>

Web項目下 /src/com.SE2/

SE2_1.java

package com.SE2;

import java.util.ArrayList;
import java.util.Random; public class SE2_1 {// Software Engineering 軟件工程 作業2
static String jia = "+";
static String jian = "-";
static String cheng = "*";
static String chu = "/";
String shizi9 = null;
RN daan9;
double daan12;
String shuru;
double shuruZH;
int zhengque, cuowu; public double strto12(String daan) {
return Math.round(Double.parseDouble(daan) * 100) / 100.0;
} public int panduan(String[] input, String[] Answer) {
int count = 0;
for (int i = 0; i < Answer.length; i++) {
if (Double.parseDouble(input[i]) == Double.parseDouble(Answer[i])
|| Double.parseDouble(input[i]) == Math.round(Double
.parseDouble(Answer[i]) * 100) / 100.0)
count++;
}
return count;
} public void setcuowu(int cuowu) {
this.cuowu = cuowu;
} public void setzhengque(int zhengque) {
this.zhengque = zhengque;
} public int getcuowu() {
return cuowu;
} public int getzhengque() {
return zhengque;
} public boolean panduandaan() {
if (daan9.getSign() == 0
&& (getshuruZH() == getdaan9number() || getshuruZH() == getdaan12()))
return true;
else if (daan9.getSign() == 2 && getshuruZH() == getdaan9number())
return true;
else
return false;
} public void setshuru(String shuru) {
this.shuru = shuru;
} public String getshuru() {
return shuru;
} public double str_daanTodouble_daan12(String daan) {
return 1;// !!!
} public void setshuruZH() {
shuruZH = Input(getshuru()).getNumber();
} public double getshuruZH() {
return shuruZH;
} public void setshizi9(String shizi) {
shizi9 = shizi;
} public String getshizi9() {
return shizi9;
} public void setdaan12byStr(String daan) {
daan12 = Math.round(Double.parseDouble(daan) * 100) / 100.0;
} public void setdaan12(double daan) {
daan12 = Math.round(daan * 100) / 100.0;
} public double getdaan12() {
return daan12;
} public void setdaan9(RN daan) {
daan9 = daan;
setdaan12(daan9.getNumber());
} public RN getdaan9() {
return daan9;
} public double getdaan9number() {
return daan9.getNumber();
} public RN Input(String input) {
RN temp = this.new RN();
if (input.contains("/")) {
temp.setMolecular(Integer.parseInt(input.substring(0,
input.indexOf("/"))));
temp.setDenominator(Integer.parseInt(input.substring(input
.indexOf("/") + 1)));
temp.setSign(2);
} else {
temp.setDecimal(Double.parseDouble(input));
temp.setSign(0);
}
return temp;
} public double jiechengdaan(int n, double all) {
if (n < 0)
return 0;
else if (n == 0)
return 1;
else if (n == 1)
return all;
else
return jiechengdaan(n - 1, n * all);
} public double jiecheng() {
int jiecheng = new Random().nextInt(10);
System.out.print(jiecheng + "!=");
return jiechengdaan(jiecheng, 1);
} public void fangfa(ArrayList<String> A, ArrayList<RN> O, String what) {
int index = A.indexOf(what);
// System.out.println(O.get(index).getNumber() + what
// + O.get(index + 1).getNumber() + "="
// + (O.get(index).getNumber() * O.get(index + 1).getNumber()));
if (what.equals(cheng)) {
O.set(index, new RN(O.get(index).getNumber()
* O.get(index + 1).getNumber(), 0));
} else if (what.equals(chu)) {
O.set(index, new RN(O.get(index).getNumber()
/ O.get(index + 1).getNumber(), 0));
} else if (what.equals(jia)) {
O.set(index, new RN(O.get(index).getNumber()
+ O.get(index + 1).getNumber(), 0));
} else {
O.set(index, new RN(O.get(index).getNumber()
- O.get(index + 1).getNumber(), 0));
}
// System.out.println("here set " + O.get(index).getNumber() + " at "
// + index);
// System.out.println("here remove " + O.get(index + 1).getNumber()
// + " from " + (index + 1) + " and remove " + A.get(index)
// + " from " + index);
O.remove(index + 1);
A.remove(index);
} public RN getAnswer(RN[] Operand, String[] AS) {
ArrayList<String> A = new ArrayList<String>();
ArrayList<RN> O = new ArrayList<RN>();
System.out.println();
for (String as : AS) {
A.add(as);
// System.out.print(as + " ");
}
System.out.println();
for (RN op : Operand) {
O.add(op);
// System.out.print(op.getNumber() + " ");
}
System.out.println();
while (A.get(0) != "=") {
if (A.contains(cheng) || A.contains(chu)) {
if (((A.contains(cheng) ^ A.contains(chu)) == true ? (A
.contains(cheng) == true ? true : false) : (A
.indexOf(cheng) < A.indexOf(chu) ? true : false)))
fangfa(A, O, cheng);
else
fangfa(A, O, chu);
} else if (A.contains(jia) || A.contains(jian)) {
if (((A.contains(jia) ^ A.contains(jian)) == true ? (A
.contains(jia) == true ? true : false) : (A
.indexOf(jia) < A.indexOf(jian) ? true : false)))
fangfa(A, O, jia);
else
fangfa(A, O, jian); } else
System.out.println("error!!");
O.trimToSize();
A.trimToSize();
}
return O.get(0);
} // public RN GA(int number) {// Generation algorithm 生成算式
// RN[] Operand = new RN[number];
// String[] AS = new String[number];
// AS[number - 1] = "=";
// for (int i = 0; i < number; i++) {// 生成 number 个操作数
// Operand[i] = new RN();
// switch (new Random().nextInt(2) + 1) {// 這裏設置了Int(2)+1略過 小數
// // ifInt(3)就會出現小數
// case 0:// 小数[0~1.0) *100
// do
// Operand[i]
// .setDecimal(((int) (new Random().nextDouble() * 19900)) / 100.0 - 99);
// while (Operand[i].getDecimal() == 0);
// Operand[i].setSign(0);
//
// break;
// case 1:// 整数[0~n)
// do
// Operand[i].setInteger(new Random().nextInt(199) - 99);
// while (Operand[i].getInteger() == 0);
// Operand[i].setSign(1);
// break;
// case 2:// 分数
// do
// Operand[i].setMolecular(new Random().nextInt(199) - 99);
// while (Operand[i].getMolecular() == 0);
// Operand[i].setDenominator(new Random().nextInt(99) + 1);
// Operand[i].setSign(2);
// break;
// default:
// System.exit(0);
// }
// if (i > 0)
// switch (new Random().nextInt(4)) {
// case 0:
// AS[i - 1] = jia;
// break;
// case 1:
// AS[i - 1] = jian;
// break;
// case 2:
// AS[i - 1] = cheng;
// break;
// case 3:
// AS[i - 1] = chu;
// break;
// default:
// System.exit(0);
// }
// }
// for (int i = 0; i < number; i++)
// System.out.print((Operand[i].getNumber() < 0 ? "(" : "")
// + Operand[i].toString()
// + (Operand[i].getNumber() < 0 ? ")" : "") + " " + AS[i]
// + " ");
// return getAnswer(Operand, AS);
// }
public void GA() {// Generation algorithm 生成算式
int number = new Random().nextInt(4) + 2;
RN[] Operand = new RN[number];
String[] AS = new String[number];
AS[number - 1] = "=";
String shizi2 = "";
for (int i = 0; i < number; i++) {// 生成 number 个操作数
Operand[i] = new RN();
switch (new Random().nextInt(2) + 1) {// 這裏設置了Int(2)+1略過 小數
// ifInt(3)就會出現小數
case 0:// 小数[0~1.0) *100
do
Operand[i]
.setDecimal(((int) (new Random().nextDouble() * 19900)) / 100.0 - 99);
while (Operand[i].getDecimal() == 0);
Operand[i].setSign(0); break;
case 1:// 整数[0~n)
do
Operand[i].setInteger(new Random().nextInt(199) - 99);
while (Operand[i].getInteger() == 0);
Operand[i].setSign(1);
break;
case 2:// 分数
do
Operand[i].setMolecular(new Random().nextInt(199) - 99);
while (Operand[i].getMolecular() == 0);
Operand[i].setDenominator(new Random().nextInt(99) + 1);
Operand[i].setSign(2);
break;
default:
System.exit(0);
}
if (i > 0)
switch (new Random().nextInt(4)) {
case 0:
AS[i - 1] = jia;
break;
case 1:
AS[i - 1] = jian;
break;
case 2:
AS[i - 1] = cheng;
break;
case 3:
AS[i - 1] = chu;
break;
default:
System.exit(0);
}
}
for (int i = 0; i < number; i++) {
// System.out.print((Operand[i].getNumber() < 0 ? "(" : "")
// + Operand[i].toString()
// + (Operand[i].getNumber() < 0 ? ")" : "") + " " + AS[i]
// + " ");
shizi2 = shizi2.concat((Operand[i].getNumber() < 0 ? "(" : "")
+ Operand[i].toString()
+ (Operand[i].getNumber() < 0 ? ")" : "") + " " + AS[i]
+ " ");
}
setshizi9(shizi2);
setdaan9(getAnswer(Operand, AS));
// return shizi2;
} // public static void main(String[]args){
// SE2_1 test=new SE2_1();
// test.GA();
// System.out.println("式子为:"+test.getshizi9()+"答案为:"+test.getdaan9number()+"四舍五入之后:"+test.getdaan12());
// }
// public static void main(String[] args) {
// SE2_1 test = new SE2_1();
// Scanner in = new Scanner(System.in);
// int count = 0;
// int Num;
// do {
// System.out.println("請輸入出題的個數(不超過5):");
// Num = in.nextInt();
// } while ((Num > 5 || Num < 1) ? true : false);
// for (int i = 0; i < Num; i++) {
// RN Answer = test.GA(new Random().nextInt(4) + 2);// 确定操作数个数 1~5个RN
// // System.out.println("Answer is:" + Answer.getNumber());
// RN Input = Input(in.next(), test.new RN());
// // System.out.println(Input.getNumber());
// if (Input.getNumber() == Answer.getNumber()
// || Input.getNumber() == Math
// .round(Answer.getNumber() * 100) / 100.0) {
// System.out.println("答對了!");
// count++;
// } else
// System.out.println("答錯了!答案爲:"
// + Math.round(Answer.getNumber() * 100) / 100.0);
// }
// System.out
// .println("一共" + Num + "道題,答對了" + count + "道題,答錯了"
// + (Num - count) + "道題,正確率爲:" + (double) count * 100
// / Num + "%");
// } public class F {// Fraction 分數
int Molecular;// 分子
int Denominator = 0;// 分母 void setMolecular(int Molecular) {
this.Molecular = Molecular;
} int getMolecular() {
return Molecular;
} void setDenominator(int Denominator) {
this.Denominator = Denominator;
} int getDenominator() {
return Denominator;
} double getAll() {
return (double) Molecular / Denominator;
} public String toString() {
return Molecular + "/" + Denominator;
}
} public class RN {// Random Number 隨機數
double Decimal;// 小數
int Integer;// 整數
F Fraction = new F();// 分數 int Sign;// 標誌該對象中存儲的是什麼數 public RN() { } public RN(double Decimal, int Sign) {
this.Decimal = Decimal;
this.Sign = Sign;
} void setDecimal(double Decimal) {
this.Decimal = Decimal;
} double getDecimal() {
return Decimal;
} void setInteger(int Integer) {
this.Integer = Integer;
} int getInteger() {
return Integer;
} void setMolecular(int Molecular) {
this.Fraction.setMolecular(Molecular);
} int getMolecular() {
return this.Fraction.getMolecular();
} void setDenominator(int Denominator) {
this.Fraction.setDenominator(Denominator);
} int getDenominator() {
return this.Fraction.getDenominator();
} void setSign(int Sign) {
this.Sign = Sign;
} int getSign() {
return Sign;
} double getNumber() {
switch (Sign) {
case 0:
return Decimal;
case 1:
return Integer;
case 2:
return Fraction.getAll();
default:
return -1;
}
} public String toString() {
return Fraction.getDenominator() == 0 ? (Integer == 0 ? Decimal
+ "" : Integer + "") : Fraction.toString();
}
}
}

程序執行截圖:

開始界面(第一次進入有提示輸入用戶名)

提示輸入題量:

修改背景顏色:

若輸入的值超過5或小於1,則會出錯:

出題界面:

輸入答案:

提交答案,顯示統計界面:

开发环境:Eclipse,js,css,html

程序完成的方向

1.可以出表达式里含有负整数(负整数最小不小于-100)的题目,且负数需要带括号,用户输入的结果不用带括号。如: 2*(-4) = -8。
2.用户答题结束以后,程序可以显示用户答题所用的时间。
3.用户可以选择出题的个数(最多不能超过5个题目),答题结束可以显示用户答错的题目个数和答对的题目个数。
4.用户在第一次答题时,需要用户输入用户名,用户下次启动后,程序需要记住用户前一次输入的用户名 。
5.程序可以出单个整数阶乘的题目:如:4!=24。
6.程序可以设置答题时间,时间设置为整数,单位为秒,最大不能超过120秒,若超过了答题时间未答题,则提示:时间已到,不能答题。
7程序可以设置皮肤功能,可以改变界面的颜色即可。

结对同伴:

姓名 学号 博客地址
叶子鹏 201306114420 http://www.cnblogs.com/kazehanaai/
王佳宁 201306114434 http://www.cnblogs.com/paopaotai/

预计用时7天,实际用时6天。

分工:我:编写主要核心算法。   我的小伙伴:界面的设计排版,提供思路,测试排除错误。

總結:

由於時間比較趕,技術還不過關,勉強做出了一點功能,

其中

1.階乘功能已經做出,但是還未嵌入.

2.用戶輸入有效性還沒測試.

3.括號式子功能還沒弄出來.

4.java裏面很多沒用的功能和參數或對象都還沒來得及清理出來..請諒解下哈..第一次做想做的模式,不再是java或者C那些了(笑

以上是這次作業的成果.還有很多要改善的地方,請加分.謝謝!!有很多不足的地方,還望指教~!

20150401 作业2 结对 四则运算ver 1.0的更多相关文章

  1. 20150401 作业2 结对 四则运算(Doing)

    import java.util.ArrayList; import java.util.Random; import java.util.Scanner; public class SE2_1 {/ ...

  2. 结对作业——随机生成四则运算(Core 第7组)

    结对作业 ——随机生成四则运算(core第7组) 吕佳玲 PB16060145 涂涵越 PB16060282 GITHUB地址 https://github.com/hytu99/homework_2 ...

  3. 第二次作业:结对编程,四则运算的GUI实现

    小伙伴:201421123031 余洋 201421123044  潘志坚  题目要求: 我们在个人作业1中,用各种语言实现了一个命令行的四则运算小程序.进一步,本次要求把这个程序做成GUI(可以是W ...

  4. 【第二次个人作业】结对作业Core第一组:四则运算生成PB16061082+PB16120517

    [整体概况] 1.描述最终的代码的实现思路以及关键代码. 2.结对作业两个人配合的过程和两个人分工. 3.API接口文档和两个组的对接. 4.效能分析,优化分析和心得体会. [代码实现] 一. 实现功 ...

  5. 【软件工程第三次作业】结对编程:四则运算( Java 实现)

    1. GitHub 地址 本项目由 莫少政(3117004667).余泽端(3117004679)结对完成. 项目 GitHub 地址:https://github.com/Yuzeduan/Arit ...

  6. 复利计算--结对项目<04-11-2016> 1.0.0 lastest 阶段性完工~

    结对项目:Web复利计算 搭档博客地址:25江志彬  http://www.cnblogs.com/qazwsxedcrfv/ 个人摘要: (2016-04-09-12:00)补充:之前传送门没做好, ...

  7. 第三次作业:结对编程--实现表格在APP的导入和显示

    031302517 031302319 ps:共同完成一篇随笔,文章中的第一人称我(517),队友(319) 一.功能分析+实现思路+结队讨论 这里我将功能分析和实现思路还有结对过程中的一些讨论结合在 ...

  8. 四则运算ver.mk2

    package size; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JMenuBar; im ...

  9. 作业1+2.四则运算(改进后完整版,用python写的)_064121陶源

    概述: 用一个星期加上五一的三天假期自学了python,在Mac系统上重新写出了四则运算的程序,编译器是PyCharm,相当于完成了作业2.d)"选一个你从来没有学过的编程语言,试一试实现基 ...

随机推荐

  1. PyQt5--QSplitter

    # -*- coding:utf-8 -*- ''' Created on Sep 20, 2018 @author: SaShuangYiBing Comment: ''' import sys f ...

  2. UVa 11846 - Finding Seats Again

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  3. CNTA-2019-0014 wls9-async 反序列化 rce 分析

    在调试weblogic,以前导入jar包都是在weblogic目录搜索*.jar拷贝出来在导入IDEA.有时候会出现好多相同的jar包,调试的时候就会出问题,实际上导入以下俩个包就可以了.1.是mod ...

  4. mysql数据类型介绍(含text,longtext,mediumtext说明)

    转自http://m.blog.csdn.net/sipsir/article/details/12343581 转载,文章原连接已经失效,百度快照找到的. MySQL支持大量的列类型,它可以被分为3 ...

  5. AI 循环神经网络

    循环神经网络(Recurrent Neural Network,简称RNN),通常用于处理序列数据,正如卷积神经网络用于处理网格数据那样.

  6. ASP.NET Newtonsoft 序列化反序列化

    1.NuGet 安装 Newtonsoft 2.调用方法 一 NuGet 安装 Newtonsoft 二 调用方法 Student stu = new Student(); stu.ID = &quo ...

  7. 【Codeforces 1129C】Morse Code

    Codeforces 1129 C 题意:给一个0/1串,问它的每一个前缀中的每一个子串能解析成莫尔斯电码的串的种数. 思路:首先对于这个串构造后缀自动机,那么从起点走到每一个节点的每一条路径都代表了 ...

  8. SkylineDemoForWeb JavaScript二次开发示例代码

    SkylineDemoForWeb JavaScript二次开发示例代码 http://files.cnblogs.com/files/yitianhe/SkylineDemoForWeb.zip

  9. SkylineGlobe API 如何以图层的方式导入MPT地形

    测试环境:TerraExplorer Pro 6.6; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&qu ...

  10. Java多线程编程模式实战指南(三):Two-phase Termination模式

    停止线程是一个目标简单而实现却不那么简单的任务.首先,Java没有提供直接的API用于停止线程.此外,停止线程时还有一些额外的细节需要考虑,如待停止的线程处于阻塞(等待锁)或者等待状态(等待其它线程) ...