91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 13KB
    文件類型: .java
    金幣: 1
    下載: 0 次
    發布日期: 2021-05-06
  • 語言: Java
  • 標簽: java??

資源簡介

編寫一個小學生整數四則運算練習軟件,每次運行程序時要求先輸入用戶名,之后計算機隨機生成題目,程序每次顯示一道題目,要求用戶輸入答案,之后詢問用戶是否要繼續。如果用戶選擇不繼續,則程序再顯示全部題目,標準答案和用戶的答案,并給出得分(每道題目的分值為100.0/題目數)。同時,將題目、標準答案、用戶答案、成績保存到以用戶名為文件夾,以rec+日期時間為文件名的文本文件中。要求文件的排版美觀整齊,用戶可以用記事本查看該文件的內容。 要求程序提供完善的異常處理。 主類的類名必須是ArithmeticTest6,源程序文件名必須是ArithmeticTest6.java。

資源截圖

代碼片段和文件信息

import?java.util.*;
import?java.io.*;

public?class?ArithmeticTest6?{

static?String?sure1(String?x)throws?MyException{
if(!(x.equals(“+“)||x.equals(“-“)||x.equals(“X“)||x.equals(“/“)||x.equals(“r“)))?{
?throw?new?MyException(“運算類型錯誤“);}
?return?x;

}
static?String?sure2(String?y)throws?MyException{

?if(!(y.equals(“1“)||y.equals(“2“)||y.equals(“3“)||y.equals(“4“)||y.equals(“5“)))?{?
?throw?new?MyException(“輸入數據類型錯誤“);}
?return?y;

}
static?void?sure3(int?xString?yString?z)throws?NumberTooBigException{

int?y1=Integer.parseInt(y);
if(z.equals(“+“))?{if(x<0||x>Math.pow(10y1)*2)
?throw?new?NumberTooBigException(“你輸入的答案超出了可能的范圍請重新輸入“);}
else?if(z.equals(“-“))?{if(x<0||x>=Math.pow(10y1)*1)
?throw?new?NumberTooBigException(“你輸入的答案超出了可能的范圍請重新輸入“);}
else?if(z.equals(“X“))?{if(x<0||x>Math.pow(10y1)*Math.pow(10?y1))
?throw?new?NumberTooBigException(“你輸入的答案超出了可能的范圍請重新輸入“);}
else?if(z.equals(“/“))?{if(x<0||x>Math.pow(10y1)*1)
?throw?new?NumberTooBigException(“你輸入的答案超出了可能的范圍請重新輸入“);}

?
}?

public?static?void?main(String[]?args)?throws?Exception?{
?

int?numberOfDigit;
int?score?=?0;?
int?iscontinue?=?1;
BufferedReader?in=new?BufferedReader(new?InputStreamReader(System.in));
String?name=in.readLine();
File?f=new?File(name);?
if(!f.exists())?f.mkdir();
Calendar?time=Calendar.getInstance();
String?Time=String.format(“%1$ty_%1$tm_%1$td?%1$tH_%1$tM_%1$tS“time);
numberOfDigit?=?Integer.parseInt(args[1]);
Random?numberGenerator?=?new?Random(new?Date().getTime());
BufferedReader?keyboardIn?=?new?BufferedReader(new?InputStreamReader(System.in));


try?{String?s1=sure1(args[0]);
String?s2=sure2(args[1]);
}?
catch?(MyException?e)?{
System.out.println(e.getMessage());
System.exit(1);
}
?

?
if?(args[0].equals(“r“))?{
Vector?array?=?new?Vector();
while?(iscontinue?==?1)?{
int?operators?=?numberGenerator.nextInt((int)?(Math.pow(2?2)));
Thread.sleep(100);
if?(operators?==?0)?{
Operation?s?=?new?Addition(numberOfDigit?numberGenerator);
array.add(s);
s.outQuestion();
s.Operate();
s.ppnumber?=?Integer.parseInt(keyboardIn.readLine());

try?{sure3(s.ppnumberargs[1]“+“);}
catch?(NumberTooBigException?e)?{
System.out.println(e.getMessage());
s.ppnumber?=?Integer.parseInt(keyboardIn.readLine());
}
s.check();
System.out.println(“繼續請輸入1,終止請輸入0:“);
iscontinue?=?Integer.parseInt(keyboardIn.readLine());
}?else?if?(operators?==?1)?{
Operation?s?=?new?Subtraction(numberOfDigit?numberGenerator);
array.add(s);
s.outQuestion();
s.Operate();
s.ppnumber?=?Integer.parseInt(keyboardIn.readLine());
try?{sure3(s.ppnumberargs[1]“-“);}
catch?(NumberTooBigException?e)?{
System.out.println(e.getMessage());
s.ppnumber?=?Int

評論

共有 條評論