Java学习day016 计算税费、预测学费、计算贷款、体重指标程序

这篇博客介绍了四个Java小程序的实现,包括计算个人所得税、预测未来学费增长、计算贷款月供及总还款额,以及计算身体质量指数(BMI)。程序涉及用户输入和简单的数学计算,例如根据税率计算税费,按年增长率预测学费,应用贷款公式计算月供,以及根据体重和身高计算BMI值。
摘要由CSDN通过智能技术生成

day016  Java小作业

赶上课程布置的作业,更新几个java小程序,老师要求还要写伪代码,前面更新了如何写伪代码但是写的还需要再锻炼就不展示了。


1.计算税费

Problem: Computing Taxes

The United States federal personal income tax is calculated based on filing status and taxable income. There are four filing statuses: single filers, married filing jointly, married filing separately, and head of household. The tax rates vary every year. Table 3.2 shows the rates for 2009. If you are, say, single with a taxable income of $10,000, the first $8,350 is taxed at 10% and the other $1,650 is taxed at 15%. So, your tax is $1,082.5

you are to write a program to compute personal income tax. Your program should prompt the user to enter the filing status and taxable income and compute the tax. Enter 0 for single filers, 1 for married filing jointly, 2 for married filing separately, and 3 for head of household. Your program computes the tax for the taxable income based on the filing status.

下面是这个程序的完整代码:

/*
 *@zzhao
*/

package HelloJava;

import java.util.Scanner; 

public class ComputingTaxes 
{
	  public static void main(String[] args) 
	  {
	    // Create a Scanner
	    Scanner input = new Scanner(System.in);

	    // Prompt the user to enter filing status
	    System.out.print(
	      "(0-single filer, 1-married jointly or qualifying widow(er), "
	      + "\n2-married separately, 3-head of household)\n" +
	      "Enter the filing status: ");
	    int status = input.nextInt();

	    // Prompt the user to enter taxable income
	    System.out.print("Enter the taxable income: ");
	    double income = input.nextDouble();

	    // Compute tax
	    double tax = 0;

	    if (status ==
  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值