私有字符串符號;//代表股票代碼。
私有字符串名稱;//表示股票的名稱。
私人雙倍先前收盤價格;//代表前壹期的收盤價。
私有雙倍貨幣價格;//表示當前價格。
Public stock(字符串符號,字符串名稱)//用代碼和名稱創建壹個股票對象。
{
this.symbol = symbol
this.name = name
}
公共字符串getSymbol() {
返回符號;
}
公共字符串getName() {
返回名稱;
}
public double getPreviousClosingPrice(){
返回以前的收盤價格;
}
public void setPreviousClosingPrice(兩倍的previousClosingPrice) {
this . previousClosingPrice = previousClosingPrice;
}
public double getCurrentPrice() {
返回當前價格;
}
public void setCurrentPrice(double current price){
this . current price = current price;
}
public double changePeercent()
{
return math . round((getCurrentPrice()/getPreviousClosingPrice()* 100));
}
公共靜態void main(String[] args)
{
股票st =新股票(“IBM”,“國際商業制造公司”);
ST . setpreviousclosingprice(176);
ST . setcurrentprice(153);
system . out . println(ST . changepeercent()+“%”);
}
}