/**
* 财务应用程序:计算小费。
* 读入一笔费用与酬金率,计算酬金(gratuity)和总钱数(total)。
* 例如,如果用户输入10作为费用(cost),15%作为酬金率(rates),计算结果显示酬金为$1.5,总费用为$11.5。
* 下面是一个运行示例:
* ————————————————————————————————————————————————————
* | Enter the subtotal and a gratuity rate: 20.55 15 |
* | The gratuity is 20.55 and total is 23.6325 |
* ————————————————————————————————————————————————————
*/
package Test;
import java.util.Scanner;
public class T25 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the subtotal and a gratuity rate: ");
double cost = input.nextDouble();
double rates = input.nextDouble();
double gratuity = cost * (rates / 100);
double total = gratuity + cost;
System.out.println("The gratuity is " + cost + " and total is " + total);
}
}
第2章:财务应用程序:计算小费
最新推荐文章于 2022-09-21 21:44:31 发布