freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

java實(shí)驗(yàn)報(bào)告-資料下載頁

2025-02-04 15:15本頁面

【導(dǎo)讀】如果輸入月份為2月份,則程序提示讓用戶輸入年份,再輸出結(jié)果。使用Java編寫控制臺應(yīng)用程序

  

【正文】 } } public class Experiment10_2 { public static void main(String arg[]){ TrafficTool car = new Car()。 String a=()。 (a)。 TrafficTool plane = new Plane()。 String b=()。 (b)。 } } 實(shí)驗(yàn)十一 ? 1 定義一個樂器 (Instrument)接口,其中有抽象方法: void play()。 ? 在 InstrumentTest類中,定義一個方法: void playInstrument(Instrument ins) ? 并在該類的 main方法中調(diào)用該方法。 ? 要求:分別使用下列內(nèi)部類完成此題 ? 成員內(nèi)部類 ? 局部內(nèi)部類 ? 匿名類 interface Instrument{ void play()。 } class InstrumentTest{ public void playInstrument(Instrument ins){ ()。 } } class InstrumentImpl implements Instrument{ @Override public void play(){ (成員內(nèi)部類 )。 } } public class Experiment11_1{ public static void main(String[] agrs){ InstrumentTest instrument = new InstrumentTest()。 (new InstrumentImpl ())。 class InstrumentImpl2 implements Instrument{ @Override public void play(){ (局部內(nèi)部類 )。 } } (new InstrumentImpl2())。 (new Instrument(){ @Override public void play(){ (匿名內(nèi)部類 )。 } })。 } } ? 2循環(huán)接受用戶從鍵盤輸入的數(shù)值,將該數(shù)值除 123的結(jié)果顯示出來 。 ? 用戶輸入的合法數(shù)據(jù)為 100至 100之間的實(shí)數(shù)(除了 “11”),如果輸入以下不合法的數(shù)據(jù)時,請給出相應(yīng)的用戶提示并繼續(xù)進(jìn)行處理 。 ? 當(dāng)用戶按數(shù)字鍵 “11”時 ? 當(dāng)用戶輸入 100至 100范圍外的數(shù)值 ? 當(dāng)用戶輸入非數(shù)值的字符串時 import .*。 class MyException1 extends Exception{ String message=不允許輸入 11。 public String getMessage(){ return message。 } } class MyException2 extends Exception{ String message=您輸入的數(shù)值在 100到 100之外 。 public String getMessage(){ return message。 } } class A{ public void f(String n) throws MyException1, MyException2{ Integer a = (n)。 if(a==11){ MyException1 ex1=new MyException1()。 throw(ex1)。 } if(a100||a100){ MyException2 ex2=new MyException2()。 throw(ex2)。 } (123/a)。 } } public class Experiment11_2 { public static void main(String arg[]){ for(。){ try{ Scanner reader=new Scanner()。 String n=()。 A a=new A()。 (n)。 } catch (MyException1 e){ (())。 } catch (MyException2 e){ (())。 } catch ( e){ (您輸入的不是數(shù)值 )。 } } } } ? 3 在定義一個銀行類時 , 有 deposit、 withdraw、 showBalance等方法。若取錢數(shù)大于余額則作為異常處理 (InsufficientFundsException) ? 產(chǎn)生異常的條件是余額少于取額 , 因此是否拋出異常要判斷條件 ? 要定義好自己的異常類,并寫一個測試類 BankTest class InsufficientFundsException extends Exception{ String message=您的取錢數(shù)大于余額 。 public String getMessage(){ return message。 } } class Bank{ int m1,m2,sum=0。 void deposit(int m1){ =m1。 sum+=m1。 } void withdraw(int m2) throws InsufficientFundsException{ =m2。 if(m2sum){ InsufficientFundsException ex1=new InsufficientFundsException()。 throw(ex1)。 } sum=m2。 } void showBalance(){ (您的余額為: +sum)。 } } public class Experiment11_3 { public static void main(String args[]){ Bank bank=new Bank()。 (100)。 try{ (200)。 } catch (InsufficientFundsException e){ (())。 } ()。 } } 實(shí)驗(yàn)十 二 1實(shí)驗(yàn)要求: ? ? 編寫一個程序,輸出一個字符串中大寫英文字母的個數(shù)、小寫英文字母的個數(shù)以及非英文字母的個數(shù) 。 ? 提示: String、 Character類 package java12。 public class textstring { public static void main(String[] args){ String s=agfhgklfhgdughuAAAAAAAASSSSSaaaaa。 int Icount=0,ucount=0,ocount=0。 for(int i=0。i()。i++){ char c=(i)。 if(c=39。a39。amp。amp。c=39。z39。){ Icount++。 } else if(c=39。A39。amp。amp。c=39。Z39。){ ucount++。 } else{ ocount++。} } (Icount+ +ucount+ +ocount )。 } } 2實(shí)驗(yàn)要求: ? 請編寫程序,將用戶輸入的字符串中的單詞逆序輸出 ? 例如:“你 我 他” → “他 我 你” ? 提示: String、 StringBuffer類 import 。 public class StringReverse { public static String reverse(String s){ StringBuffer sbuffer = new StringBuffer(s)。 ()。 return ()。 } public static void main(String[] args) { (please input a string:)。 Scanner reader = new Scanner()。 String input = ()。 if(input != null){ (reverse(input))。 } } } ? 3實(shí)驗(yàn)要求: ? 編寫程序,將下列函數(shù)轉(zhuǎn)換為 Java方法 1. f(x) = cos(x)*sin(x)*x2 2. g(x) = log(x10)*cos(sin(x)) 3. h(x) = x10+x6+3x3+e5 ? 提示: Math類 import 。 public class MathFunction { public static double fA(double x) { return (x)*(x)*x*x。 } public static double gA(double x) { return ((x, 10))*((x))。 } public static double hA(double x) { return (x,10)+(x, 6)+(x, 3)*3+(5)。 } public static void main(String[] args) { (請輸入 x值 )。 Scanner reader=new Scanner()。 double x=()。 (fA(x))。 (gA(x))。 (hA(x))。 } } 實(shí)驗(yàn)十三 ? 1 實(shí)驗(yàn)要求: ? 編寫一個程序,打印昨天的當(dāng)前時刻 ,要求按照以下格式輸出: ? Current time yesterday:2021年 05月 31日 09:時 59:分 37:秒 (星期一 ) 北京時間。 ? 提示: Date、 SimpleDateFormat類 package mydate。 import 。 import 。 public class mydate { public static void Currenttimeyesterday() { long l=24*60*60*1000。 Date date=new Date(()+l)。 SimpleDateFormat sdf=new SimpleDateFormat(39。Current time yesterday39。:yyyy39。年 39。MM39。月 39。dd39。日 39。HH:39。時 39。: mm39。分 39。: ss39。秒 39。(EE)39。北京時間 39。)。 ((date))。 } public static void main(String[] args) { // TODO Autogenerated method stub Currenttimeyesterday()。 } } ? 實(shí)驗(yàn)要求: ? 編寫一個程序,根據(jù)輸入的年份和月份,輸出月歷 ? 運(yùn)行結(jié)果示例: 請輸入年份: 2021 請輸入月份: 5 ? 提示: Calendar類 package mydate。 import 。 import 。 public class date { public static void display(int year,int month) { Calendar cal=()。 (year,month1,01)。 int 星期幾 =()1。 String []a=new String[星期幾 +30]。 for (int i=0。i星期幾 。i++) a[i]=。 for(int i=星期幾 ,n=1。i星 期幾 +30。i++){ a[i]=(n)。 n++。 } (+year+年 +month+月 )。 (%9s%9s%9s%9s%9s%9s%9s\
點(diǎn)擊復(fù)制文檔內(nèi)容
試題試卷相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1