第2章:财务应用程序:工资单

/**
 * 财务应用程序:工资单。
 * 读入下列信息并打印工资单:
 * 雇员的名字(Smith)。
 * 每周工作的小时数(10)。(hours)
 * 每小时工资(6.75)。(rate)
 * 联邦所得税税率(29%)。(federal) (federalrate)
 * 州所得税税率(9%)。(state) (staterate)
 * (1)使用控制台进行输入和输出。
 * (2)使用对话框获取输入并显示输出。
 * 下面是运行示例:
 * ——————————————————————————————————————————————
 * | Enter employee`s name: Smith               |
 * | Enter number of hours worked in a week: 10 |
 * | Enter pay rate: 6.75                       |
 * | Enter federal tax withholding rate: 0.20   |
 * | Enter state tax withholding rate: 0.09     |
 * | Employee Name: Smith                       |
 * | Hours Worked: 10.0                         |
 * | Pay Rate: 6.75                             |
 * | Gross Pay: 67.5                            |
 * | Deductions:                                |
 * | 	Federal Withhoulding (20.0%): 13.5      |
 * | 	State Withhoulding (9.0%): 6.075        |
 * | 	Total Deduction: 19.575                 |
 * | Net Pay: 47.925                            |
 * ——————————————————————————————————————————————
 */
package Test;

import java.util.Scanner;

public class T211Scanner {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.print("Enter employee`s name: ");
		String name = input.nextLine();
		System.out.print("Enter number of hours worked in a week: ");
		double hours = input.nextInt();
		System.out.print("Enter pay rate: ");
		double rate = input.nextDouble();
		System.out.print("Enter federal tax withholding rate: ");
		double federal = input.nextDouble();
		System.out.print("Enter state tax withholding rate: ");
		double state = input.nextDouble();
		
		double pay = hours * rate;
		double federalrate = pay * federal;
		double staterate = pay * state;
		double total = federalrate + staterate;
		double totalpay = pay - total;
		
		System.out.println("Employee Name: " + name);
		System.out.println("Hours Worked: " + hours);
		System.out.println("Pay Rate: " + rate);
		System.out.println("Gross Pay: " + pay);
		
		System.out.println("Deductions: \n" + "\tFederal Withhoulding (20.0%): " + federalrate
				+ "\n\t" + "State Withhoulding (9.0%): " + staterate
				+ "\n\t" + "Total Deduction: " + total
				+ "\nNet Pay: " + totalpay);
	}

}


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值