我是靠谱客的博主 天真煎蛋,最近开发中收集的这篇文章主要介绍第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章:财务应用程序:计算小费所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部