/**
* 财务应用程序:计算小费。
* 读入一笔费用与酬金率,计算酬金(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章:财务应用程序:计算小费
最新推荐文章于 2023-11-15 15:59:02 发布
本文介绍了一个财务应用程序,用于计算餐饮消费后的合理小费。通过输入消费总额和期望的酬金比例,程序能准确计算出小费金额及总消费额。
1666

被折叠的 条评论
为什么被折叠?



