返回列表 發帖

507-停車費用計算

  1. public class JPD05 {
  2.     public static void main(String[] argv) {
  3.         int hours = 0;   //停車時數

  4.         hours = 2;
  5.         park(hours);
  6.         System.out.println("--------------------");
  7.         
  8.         hours = 3;
  9.         park(hours);
  10.         System.out.println("--------------------");
  11.         
  12.         hours = 5;
  13.         park(hours);
  14.         System.out.println("--------------------");
  15.         
  16.         hours = 8;
  17.         park(hours);
  18.     }
  19.    
  20.     public static void park(int hours) {
  21.         int[] hourTable = {0, 2, 4, 6};   // 時段
  22.         int[] feeTable = {30, 50, 80, 100};   // 時段費率
  23.         int fee = 0;   //停車費用
  24.         
  25.         ...

  26.         System.out.println("應繳費用:" + fee + "元整");
  27.     }
  28. }
複製代碼
Stay hungry,
Stay foolish.

返回列表