System.out.println("请输入您要修改的虚部:");
double n=0;
try{
n= Double.parseDouble(in.readLine());
}
catch(IOException e)
{ System.out.println("抛掷异常");}
b.xb=n;
System.out.println("修改成功:");
return 0;
}
public static double jia(double a,double b)//
{
double c=0;
c=a+b;
System.out.println("加法成功:");
return c ;
}
public static double jian(double a,double b)
{
double c=0;
c=a-b;
System.out.println("减法成功:");
return c;
}
public static double cheng(double a,double b)
{
double c=0;
c=a*b;
System.out.println("乘法成功:");
returnc;
}
public static double chu(double a,double b)
{
double d=0;
double c=0;
d=a/b;
c=(double)(Math.round(d*100)/100.0);
System.out.println("除法成功:");
return c ;
}
publicstatic double toString(Book a){
System.out.println("结果为:"+a.sb+"+"+a.xb+"*i");
return 0;
}
}
(3)测试结果截图:
java课程设计“小学算术运算测试程序”花测试加减法的JAVA代码了好几个小时,测试通过,希望楼主多给点分
import java.util.Scanner;
class Question{
private int firstParam;
private int secondParam;
private String operator;
private int answer;
private int score;
public int getFirstParam() {
return firstParam;
}
public void setFirstParam(int firstParam) {
this.firstParam = firstParam;
}
public int getSecondParam() {
return secondParam;
}
public void setSecondParam(int secondParam) {
this.secondParam = secondParam;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public int getAnswer() {
return answer;
}
public void setAnswer(int answer) {
this.answer = answer;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
//构造
public Question(int firstParam, int secondParam) {
this.firstParam = firstParam;
this.secondParam = secondParam;
}
}
public class StudentStudy {
private int questionNumber;
private String operator;
private Question[] questions;
private int rightNumber=0;
private int wrongNumber=0;
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public int getQuestionNumber() {
return questionNumber;
}
public void setQuestionNumber(int questionNumber) {
this.questionNumber = questionNumber;
}
public int getRightNumber() {
return rightNumber;
}
public void setRightNumber(int rightNumber) {
this.rightNumber = rightNumber;
}
public int getWrongNumber() {
return wrongNumber;
}
public void setWrongNumber(int wrongNumber) {
this.wrongNumber = wrongNumber;
}
public Question[] getQuestions() {
return questions;
}
public void setQuestions(Question[] questions) {
this.questions = questions;
}
public int getRandom(){
return (int)(Math.random()*10);
}
public int calculateByOperator(String operator,int first,int second){
switch(operator.charAt(0)){
case '+':
return first+second;
case '-':
return first-second;
default:
return 0;
}
}
public void makeQuestion(){
mywhile:
while(questions[questionNumber-1]==null){
Question question=new Question(getRandom(),getRandom());
推荐阅读
- 直播伴侣配件使用,直播伴侣需要什么配置
- mysql服务无法启动为什么,mysql服务器无法启动怎么办
- 很多电脑能做些什么,有很多电脑可以做什么赚钱
- linux删掉命令 linux 删除命令详解
- 影视拍摄用什么场景好看,影视拍摄流程
- 电脑扩内存有什么影响吗,电脑扩充内存可以改善什么
- 日本美女直播平台,日本美女直播平台
- c语言无参函数max C语言无参函数比大小
- sap模块实习生是什么,sap各模块