⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rentalcost.java

📁 Java 入门书的源码
💻 JAVA
字号:
//Copyright (c) 1998, Arthur Gittleman
//This example is provided WITHOUT ANY WARRANTY either expressed or implied.

/* A rental car costs $30 for each of the first
 * three days, and $20 for each additional day.
 * Enter the number of rental days and output
 * the cost of the rental
 */

import iopack.Io;
public class RentalCost  {
   public static void main(String [] args)  {
       int days, cost;
       days = Io.readInt("Enter the number of rental days");
       if (days <= 3) 
            cost = 30*days;
       else
            cost = 90 + 20*(days - 3);
       System.out.println("The rental cost is $" + cost);
       Io.readString("Press any key to exit");   // Added for IDE use
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -