题目
题目概述
*2.23(驾驶费用)编写一个程序,提示用户输入驾驶的距离、每加仑多少英里的汽车燃油性能值,以及每加仑的价格,然后显示旅程的费用
运行示例
Enter the driving distance: 900.5
Enter miles per gallon: 25.5
Enter price per gallon: 3.55
The cost of driving is $125.36
思路
先建模(构建油费花销和距离等四个函数之间的关系式)
cost = (price * distance) / miles
输入变量
计算并输出即可
代码
import java.util.Scanner;
public class Test2_23 {