8个回答
展开全部
解:根据题意可得:
4÷2+9-10=2+9-10=1
4÷2+9-10=2+9-10=1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
32=2×9+4+10 36=(10-2-4)×9 48=4×9+10+2
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
建两个实体类,一个题目实体类Subject,一个试卷类Exam。package com.exam.demo;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.function.BiFunction;
/**
* 试卷实体类
*/
public class Exam {
private List<Subject> subjectList;
public List<Subject> getSubjectList() {
return subjectList;
}
public void setSubjectList(List<Subject> subjectList) {
this.subjectList = subjectList;
}
public Exam() {
int count = 10;
List<Subject> list = new ArrayList<Subject>();
BiFunction<Integer, Integer, Integer> add = (x, y) -> x + y;
BiFunction<Integer, Integer, Integer> minus = (x, y) -> x - y;
BiFunction<Integer, Integer, Integer> multiple = (x, y) -> x * y;
BiFunction<Integer, Integer, Integer> divide = (x, y) -> x / y;
for (int i = 0; i < count; i++) {
Subject subject = new Subject();
Integer a = new Random().nextInt(99);
Integer b = new Random().nextInt(99);
subject.setA(a);
subject.setB(b);
subject.setIndex(i + 1);
Integer symbol = new Random().nextInt(3);
if (symbol == 0) {
subject.setSymbol("+");
subject.setAnswer(add.apply(a, b));
} else if (symbol == 1) {
subject.setSymbol("-");
subject.setAnswer(minus.apply(a, b));
} else if (symbol == 2) {
subject.setSymbol("×");
subject.setAnswer(multiple.apply(a, b));
} else if (symbol == 3) {
subject.setSymbol("÷");
subject.setAnswer(divide.apply(a, b));
}
list.add(subject);
}
this.subjectList = list;
}
public static void main(String[] args) {
Exam exam = new Exam();// 随机出十道题
// 查看试卷
exam.getSubjectList().forEach(subject -> {
System.out.println("第" + subject.getIndex() + "题:" + subject.getA() + " " + subject.getSymbol() + " "
+ subject.getB() + " = ? 答案:" + subject.getAnswer());
});
}
}
/**
* 定义题目的类
*
*/
class Subject {
private Integer index;
private Integer a;
private Integer b;
private String symbol;
private Integer answer;
public Integer getIndex() {
return index;
}
public void setIndex(Integer index) {
this.index = index;
}
public Integer getA() {
return a;
}
public void setA(Integer a) {
this.a = a;
}
public Integer getB() {
return b;
}
public void setB(Integer b) {
this.b = b;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public Integer getAnswer() {
return answer;
}
public void setAnswer(Integer answer) {
this.answer = answer;
}
}
运行打印结果:第1题:67 + 62 = ? 答案:129第2题:54 - 66 = ? 答案:-12第3题:15 × 36 = ? 答案:540第4题:81 + 6 = ? 答案:87第5题:87 - 70 = ? 答案:17第6题:83 - 80 = ? 答案:3第7题:1 - 88 = ? 答案:-87第8题:17 × 14 = ? 答案:238第9题:57 × 31 = ? 答案:1767第10题:73 + 6 = ? 答案:79
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.function.BiFunction;
/**
* 试卷实体类
*/
public class Exam {
private List<Subject> subjectList;
public List<Subject> getSubjectList() {
return subjectList;
}
public void setSubjectList(List<Subject> subjectList) {
this.subjectList = subjectList;
}
public Exam() {
int count = 10;
List<Subject> list = new ArrayList<Subject>();
BiFunction<Integer, Integer, Integer> add = (x, y) -> x + y;
BiFunction<Integer, Integer, Integer> minus = (x, y) -> x - y;
BiFunction<Integer, Integer, Integer> multiple = (x, y) -> x * y;
BiFunction<Integer, Integer, Integer> divide = (x, y) -> x / y;
for (int i = 0; i < count; i++) {
Subject subject = new Subject();
Integer a = new Random().nextInt(99);
Integer b = new Random().nextInt(99);
subject.setA(a);
subject.setB(b);
subject.setIndex(i + 1);
Integer symbol = new Random().nextInt(3);
if (symbol == 0) {
subject.setSymbol("+");
subject.setAnswer(add.apply(a, b));
} else if (symbol == 1) {
subject.setSymbol("-");
subject.setAnswer(minus.apply(a, b));
} else if (symbol == 2) {
subject.setSymbol("×");
subject.setAnswer(multiple.apply(a, b));
} else if (symbol == 3) {
subject.setSymbol("÷");
subject.setAnswer(divide.apply(a, b));
}
list.add(subject);
}
this.subjectList = list;
}
public static void main(String[] args) {
Exam exam = new Exam();// 随机出十道题
// 查看试卷
exam.getSubjectList().forEach(subject -> {
System.out.println("第" + subject.getIndex() + "题:" + subject.getA() + " " + subject.getSymbol() + " "
+ subject.getB() + " = ? 答案:" + subject.getAnswer());
});
}
}
/**
* 定义题目的类
*
*/
class Subject {
private Integer index;
private Integer a;
private Integer b;
private String symbol;
private Integer answer;
public Integer getIndex() {
return index;
}
public void setIndex(Integer index) {
this.index = index;
}
public Integer getA() {
return a;
}
public void setA(Integer a) {
this.a = a;
}
public Integer getB() {
return b;
}
public void setB(Integer b) {
this.b = b;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public Integer getAnswer() {
return answer;
}
public void setAnswer(Integer answer) {
this.answer = answer;
}
}
运行打印结果:第1题:67 + 62 = ? 答案:129第2题:54 - 66 = ? 答案:-12第3题:15 × 36 = ? 答案:540第4题:81 + 6 = ? 答案:87第5题:87 - 70 = ? 答案:17第6题:83 - 80 = ? 答案:3第7题:1 - 88 = ? 答案:-87第8题:17 × 14 = ? 答案:238第9题:57 × 31 = ? 答案:1767第10题:73 + 6 = ? 答案:79
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询