rentalcost.java
来自「Java 入门书的源码」· Java 代码 · 共 23 行
JAVA
23 行
//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 + =
减小字号Ctrl + -
显示快捷键?