package experce2;
public class thesecound {
public static void main(String[] args) {
Stock a=new Stock("ORCL","Oraclecorporation");
a.number1(34.5);
a.number2(34.35);
System.out.println(a.currenPrice+" "+a.preciousClosingPrice);
System.out.println("the changepercent is "+(int)(a.getChangePercent()*10000)/100.0+"%");
}
}
class Stock{
String symbol;//代码
String name;//名字
double preciousClosingPrice;//前一日股票
double currenPrice;//当前股票
Stock (String a,String b){
symbol=a;
name=b;
}
void number1 (double c){
preciousClosingPrice= c;
}
void number2(double d) {
currenPrice=d;
}
double getChangePercent(){
return (1-currenPrice/preciousClosingPrice);
}