我是靠谱客的博主 天真煎蛋,这篇文章主要介绍第2章:财务应用程序:计算小费,现在分享给大家,希望可以做个参考。

/**
 * 财务应用程序:计算小费。
 * 读入一笔费用与酬金率,计算酬金(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章:财务应用程序:计算小费的全部内容,更多相关第2章内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(118)

评论列表共有 0 条评论

立即
投稿
返回
顶部