![Java實(shí)驗(yàn)報(bào)告修改版_第1頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-2/15/c8782bb5-31e2-4787-bc1e-8bcedf37fa84/c8782bb5-31e2-4787-bc1e-8bcedf37fa841.gif)
![Java實(shí)驗(yàn)報(bào)告修改版_第2頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-2/15/c8782bb5-31e2-4787-bc1e-8bcedf37fa84/c8782bb5-31e2-4787-bc1e-8bcedf37fa842.gif)
![Java實(shí)驗(yàn)報(bào)告修改版_第3頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-2/15/c8782bb5-31e2-4787-bc1e-8bcedf37fa84/c8782bb5-31e2-4787-bc1e-8bcedf37fa843.gif)
![Java實(shí)驗(yàn)報(bào)告修改版_第4頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-2/15/c8782bb5-31e2-4787-bc1e-8bcedf37fa84/c8782bb5-31e2-4787-bc1e-8bcedf37fa844.gif)
![Java實(shí)驗(yàn)報(bào)告修改版_第5頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-2/15/c8782bb5-31e2-4787-bc1e-8bcedf37fa84/c8782bb5-31e2-4787-bc1e-8bcedf37fa845.gif)
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、開課實(shí)驗(yàn)室:現(xiàn)代信息交流中心403 開課時(shí)間: 2015年3月1日 實(shí)驗(yàn)報(bào)告:2015年4月8日 學(xué)院名稱信息工程學(xué)院年級(jí)、專業(yè)、班信管1303班學(xué)號(hào)姓名張?jiān)粕M姓名無(wú)課程名稱Java程序設(shè)計(jì)實(shí)驗(yàn)項(xiàng)目名稱Java面向?qū)ο蟪绦蛟O(shè)計(jì)(1)指導(dǎo)教師尉斌實(shí)驗(yàn)類型驗(yàn)證 綜合 設(shè)計(jì) 創(chuàng)新 成績(jī)教師評(píng)語(yǔ) 教師簽名: 年 月 日一、 實(shí)驗(yàn)?zāi)康模菏煜ゎ悺傩?、?gòu)造方法、普通方法、對(duì)象的使用方法。二、實(shí)驗(yàn)內(nèi)容:(抄寫課本296頁(yè)8.2、8.7、8.8的題目至此。抄寫英文即可)8.2 (The stock class)Following the example of the Circle class in $8.
2、2,design a class named Stock that contains:n A string data field named symbol for the stocks symbol.n A string datd field named name for the stocks name.n A double data field named previousClosingPrice that stores the stock price for the previous day.n A constructor that creates a stock with specifi
3、ed symbol and name.n A method named getChangePercent() that returns the percentage changed from previousClosingPrice to currentPrice.Draw the UMLdiagram for the class.Implement the class.Write a test program that creates a Stock object with the stock symbol JAVA,the name Sun Microsystems Inc,and the
4、 previous closing price of 4.5.Set a new current price to 4.35 and display the price-change percentage. 8.7(The Account class)Design a class named Account that contains:n A private int data field named id for the account(default 0).n A private double 三、源代碼清單:1、源代碼清單方法一:package 實(shí)驗(yàn)2;public class shiya
5、n1 public static class Aprivate String number1;private double newPrice;public static void main(Stringargs)A symbol= new A();System.out.println("The stock number is :"+symbol.number1);A name=new A("中國(guó)銀行");System.out.println("The stock name is :"+1);A Price=new A(3900,400
6、0);System.out.println("The stock PreviousPrice is :"+Price.oldPrice);System.out.println("The stock CurrentPrice is :"+Price.newPrice);System.out.println("The stock getChangePercent is :"+Price.getChangePercent();String number11,name1;double PreviousPrice,CurrentPrice,ol
7、dPrice,newPrice1;A()number1 = "000001"A(String name2)name1=name2;A(double Price1,double Price2)oldPrice=Price1;newPrice=Price2;double getChangePercent()return (newPrice-oldPrice)/oldPrice;方法二:package 實(shí)驗(yàn)2;public class shiyan11 public static class Stock private String symbol;private String n
8、ame;public Stock(String symbol, String name)this.symbol = symbol; = name;public static void main(String args) Stock name = new Stock("JAVA", "Sun Microsystems Inc");System.out.println(name.symbol+" "+","+"The price-change percentage betwwen"+ name.pr
9、eviousClosingPrice + "and" + name.currentPrice + "is"+ name.getChangePercent();double previousClosingPrice = 4.5;double currentPrice = 4.35;double getChangePercent() return (previousClosingPrice - currentPrice) / previousClosingPrice;2、方法一:package 實(shí)驗(yàn)2;public class Account private
10、 int ID=0;private double balance=0;private double annuanIntersetRate=0;private String dataCreated="2015年1月1日"public Account (int newID)ID=newID;public int getid()return ID;public Account (double newBalance,double newAnnuanIntersetRate)balance=newBalance;annuanIntersetRate=newAnnuanInterset
11、Rate;public double getBalance()return balance;public double getannuaIntersetRate()return annuanIntersetRate/12;public Account(String newDataCreated)dataCreated=newDataCreated;public String getdataCreated()return dataCreated;public double getWithdraw()return balance-2500;public double getDeposit()ret
12、urn balance-2500+3000;package 實(shí)驗(yàn)2;public class Account1 public static void main(Stringargs)Account myID=new Account(1122);System.out.println("The ID is :"+myID.getid();Account myBalance=new Account(20000.0,0.045);System.out.println("The banlane is :"+myBalance.getBalance();System
13、.out.println("The newBalance is :"+myBalance.getWithdraw();System.out.println("The lastBalance is :"+myBalance.getDeposit();System.out.println("The data created is :"+myBalance.getdataCreated();System.out.println("The month rate is :"+myBalance.getannuaInterse
14、tRate(); 方法二:package exercise;import java.util.Date;import java.util.Scanner;public class TestAccount public static void main(String args)Account account = new Account("1122",20000);account.setAnnualInterestRate(4.5);account.withdraw(2500);account.deposit(3000);System.out.println("The
15、 balance is :"+account.getbalance();System.out.println("Monthly interest is "+ account.getMonthlyTnterest(); System.out.println("This account was created at "+ account.getDateCreated();class AccountString ID;double balance=0.0;double annualInterestRate;Date dateCreated;Accou
16、nt(String newID,double balance)ID=newID;this.balance=balance;dateCreated=new Date(); void setAnnualInterestRate(double annualInterestRate)this.annualInterestRate=annualInterestRate;public Date getDateCreated()return dateCreated;public double getbalance()return balance;public double getMonthlyTnteres
17、t()return balance * (annualInterestRate / 1200);public double withdraw(double number)balance=balance-number;return balance;public double deposit(double number)balance=balance+number;return balance;3、源代碼清單package 實(shí)驗(yàn)2;public class Fanint speed=1;boolean on=false;double radius=5;String color="blue"public Fan()public void turnOn()on=true;public void turnOff()on=false;public void setSpeed(int newSpeed)if(on&&newSpeed>=1&&newSpeed<=3)speed=newSpeed;public void setColor(String newColor)if (on
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 公司在職員工培訓(xùn)服務(wù)合同書
- 礦山企業(yè)安全生產(chǎn)許可證頒發(fā)與管理作業(yè)指導(dǎo)書
- 反擔(dān)保合同協(xié)議1
- 游戲美術(shù)設(shè)計(jì)制作實(shí)戰(zhàn)手冊(cè)作業(yè)指導(dǎo)書
- 針紡織品銷售購(gòu)銷合同
- 小學(xué)二年級(jí)數(shù)學(xué)上冊(cè)口算
- 2025年紹興a2貨運(yùn)從業(yè)資格證模擬考試題
- 2024-2025學(xué)年高中語(yǔ)文專題一小說(shuō)家想說(shuō)些什么第1課在酒樓上學(xué)案蘇教版選修短篇小說(shuō)蚜
- 七年級(jí)班級(jí)工作總結(jié)
- 四年級(jí)第一學(xué)期德育工作計(jì)劃
- 普外腹腔鏡手術(shù)護(hù)理常規(guī)
- 2024年全國(guó)職業(yè)院校技能大賽(礦井災(zāi)害應(yīng)急救援賽項(xiàng))考試題庫(kù)(含答案)
- 《預(yù)制高強(qiáng)混凝土風(fēng)電塔筒生產(chǎn)技術(shù)規(guī)程》文本附編制說(shuō)明
- C語(yǔ)言程序設(shè)計(jì) 教案
- 2025新譯林版英語(yǔ)七年級(jí)下單詞表
- 海洋工程設(shè)備保溫保冷方案
- 主干光纜、支線光纜線路中斷應(yīng)急預(yù)案
- 跨學(xué)科主題學(xué)習(xí)的思考與策略
- 文藝演出排練指導(dǎo)服務(wù)合同
- 醫(yī)院消防安全培訓(xùn)課件(完美版)
- 行政法-9行政確認(rèn)
評(píng)論
0/150
提交評(píng)論