close


public class Preson {
    public int ageYears = 1;
    public int ageDays;
    public long ageMinutes, ageSecond, ageMillisecond;
    
    public void calculateAge() {
        ageDays = ageYears*365;
        ageMinutes = ageDays*24*60;
        ageSecond = ageMinutes*60;
        ageMillisecond = ageSecond*1000;
        System.out.println("You are "+ ageDays +" old." );
        System.out.println("You are "+ ageMinutes +" old." );
        System.out.println("You are "+ ageSecond +" old." );
        System.out.println("You are "+ ageMillisecond +" old." );
        
}
}

--------------------------

public class PersonTest { // 人測試
   
  public static void main (String args[]) {
 
    Preson myPerson = new Preson(); // 建立人 
  
    myPerson.calculateAge(); // 執行年齡計算

  } 
}

----------

 

 

arrow
arrow
    全站熱搜

    蛋餅Brook 發表在 痞客邦 留言(0) 人氣()