计算小费

import javax.swing.JOptionPane;
public class Money {
    public static void main(String[] args){
    double gratuity;
    double total;
    String input = JOptionPane.showInputDialog(null,"请输入费用:","对话框",JOptionPane.QUESTION_MESSAGE);
    String input1 =JOptionPane.showInputDialog(null,"请输入酬金:","对话框",JOptionPane.QUESTION_MESSAGE);
    double subtotal = Double.parseDouble(input);
    double rate = Double.parseDouble(input1);
    gratuity = (int)(subtotal * rate * 0.01 * 100)/100.00;
    total =(int)((subtotal + gratuity)*100)/100.00;
    System.out.println("The grtuity is " + gratuity + " and total is " + total);
    }
}

读入一笔费用与酬金率,计算酬金和总金钱数。例如,如果用户输入10作为费用,15%作为酬金率,计算显示酬金¥1.5,总费用为¥11.5。

计算小费

时间: 2024-08-30 07:15:13

计算小费的相关文章

iOS开发笔记 整理(全)

退回输入键盘 - (BOOL)textFieldShouldReturn:(id)textField{ [textField resignFirstResponder]; } CGRect CGRect frame = CGRectMake (origin.x,origin.y, size.width, size.height):矩形 NSStringFromCGRect(someCG) 把CGRect结构转变为格式化字符串: CGRectFromString(aString) 由字符串恢复出矩

IOS_Note

关键字:可以搜索这些关键字找到具体内容 退回输入键盘.CGRect.CGPoint & CGSize.设置透明度.设置背景色.自定义颜色. 竖屏.横屏.状态栏高  (显示时间和网络状态). 导航栏.工具栏高(返回).隐藏状态栏.横屏.屏幕变动检测.全屏. 自动适应父视图大小.定义按钮.设置视图背景图片. 自定义 UISlider 的样式和滑块.活动表单.警告视图.动画效果.图像. 文本标签和详细文本标签.点击 textField 外的地方回收键盘. 键盘覆盖输入框.UIViewControlle

js的常见写法技巧

Javascript练习题 正则表达式验证邮箱 摘要: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta

Windows Universal 应用 – Tip Calculator

声明 以下内容取材于 Bob Tabor 的课程<Windows Phone 8.1 Development for Absolute Beginners>,链接地址为:http://www.microsoftvirtualacademy.com/training-courses/windows-phone-8-1-development-for-absolute-beginners 前言 Universal App是一种跨平台的应用开发,目前主要面向Windows和Windows Phone

第二章编程练习题2.5

import java.util.Scanner; /** * 财务应用程序,计算小费 * @author Administrator * */ public class Main3 { public static void main(String[] args) { Scanner input = new Scanner(System.in); double number = input.nextDouble(); double rate = input.nextDouble(); doubl

ios开发小知识2

http://blog.sina.com.cn/s/blog_66450b500102vadq.html http://www.cnblogs.com/lovesmile/archive/2012/06/27/2565569.html ios开发小知识2(转自cc) 退回输入键盘  - (BOOL)textFieldShouldReturn:(id)textField{    [textField resignFirstResponder];} CGRectCGRect frame = CGRe

使用R语言计算均值,方差等

R语言对于数值计算很方便,最近用到了计算方差,标准差的功能,特记录. 数据准备 height <- c(6.00, 5.92, 5.58, 5.92) 1 计算均值 mean(height) [1] 5.855 2 计算中位数 median(height) [1] 5.92 3 计算标准差 sd(height) [1] 0.1871719 4 计算方差 var(height) [1] 0.03503333 5 计算两个变量之间的相关系数 cor(height,log(height)) [1] 0

NumPy基础:数组和失量计算

NumPy : Numerical Python,是高性能科学计算和数据分析的基础包. 部分功能: ndarray:一个具有矢量算术运算和复杂广播能力的快速且节省空间的多维数组: 用于对整组数据进行快速运算的标准数学函数(无需编写循环): 用于读写磁盘数据的工具以及用于操作内存映射文件的工具: 线性代数.随机数生成以及傅里叶变换功能: 用于集成C.C++.Fortran等语言编写的代码工具: 大部分数据分析应用关注的功能: 用于

MySQL计算百分比方法介绍

根据相应条件抽出相应count数(myCount) 抽出总count数(totalCount) 计算百分比:myCount / totalCount * 100 四舍五入:使用ROUND函数ROUND(number,要保留的小数位),ROUND(myCount / totalCount * 100,1) 下面给出示例供参考: SELECT ROUND(T1.co/T2.totalCo*100,1)    FROM      (SELECT COUNT(*) AS co        FROM f