小学生数学测试软件的编写java

发布网友 发布时间:2022-04-25 15:23

我来回答

3个回答

热心网友 时间:2023-05-09 13:20

选我吧。。绝对短小精悍!

思路:
压力测试原理有两种,一种是连接测试,一种是负载测试
1,连接测试,就是多线程,不停的请求直到服务器死机或达到预期效果即可!
2,负载测试,就是一个线程的多步操作,每个线程占用服务器cpu 内存是否符合节能高效的标准,如果不是,那就优化吧

所有测试以额定用户(最大用户)为基础

热心网友 时间:2023-05-09 13:20

得了吧

热心网友 时间:2023-05-09 13:21

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Random;

public class Caculate {
private enum CalType {
Add,
Minus,
Multiply,
Divide;
public static CalType getType(String type) throws Exception{
if("+".equals(type)){
return Add;
} else if("-".equals(type)){
return Minus;
} else if("*".equals(type)){
return Multiply;
} else if("/".equals(type)){
return Divide;
} else {
throw new Exception("calulate type invalid!");
}
}
}
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
do{
System.out.print("选择题型:(+,-,*,/): ");
String strType = in.readLine();
try {
CalType calType = CalType.getType(strType);
System.out.print("题目数量: ");
int num = Integer.parseInt(in.readLine());
int count = 0;
Random rand = new Random();
while(count++ < num){
int number1 = rand.nextInt(1000);
int number2 = rand.nextInt(1000);
double result,answer;
result = 0;
System.out.println("第" + count + "题:" );
switch(calType){
case Add:
System.out.print(number1 + "+" + number2 + "=");
result = number1 + number2;
break;
case Minus:
System.out.print(number1 + "-" + number2 + "=");
result = number1 - number2;
break;
case Multiply:
System.out.println(number1 + "*" + number2 +"=");
result = number1 * number2;
break;
case Divide:
System.out.println(number1 +"/" + number2 + "=");
result = (double)number1 / number2;
}
answer = Double.parseDouble(in.readLine());
if(answer == result){
System.out.println("你答对了!");
}else{
System.out.println("你答错了,正确答案:" + result);
}
}

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}while(true);
}

}

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com