求狗的年齡

我家的狗5歲了,5歲至關於人類的多大呢?其實,狗的前兩年每年至關於人類的10.5歲,以後,每增長一年就增長四歲,那麼5歲的狗至關於人類多少年齡呢?應該是:10.5+10.5+4+4+4=33歲。java

package com.yingyong.day04;ide

import java.util.Scanner;code

public class DogAge {input

public static void main(String[] args) {
    // TODO Auto-generated method stub
     double peopleYear=0;
     System.out.println("輸入狗的年齡:");
     Scanner input=new Scanner(System.in);
     double yaer= input.nextDouble();
     if (yaer<=2.0){
         yaer= yaer*10.5;
         System.out.println(yaer);
     }
     else {
         double a=2.0*10.5;
         yaer=yaer-2.0;
         yaer= yaer*4;
         yaer+=a;
         System.out.println(yaer);
     }

}

}
結果:1 10.5it

相關文章
相關標籤/搜索