//package project1;
import java.util.*;
/**
* @author Deng He
* Use this TaxCalculate system, you can get the tax
* you need to pay. Of course, you can't input the wrong
* information. Take intention to the tips such as "Y"and
* "N".
*/
public class TaxCalculate
{
public static void main(String[] args)
{
Menu choicemenu= new Menu();
String input="Y";
do{
choicemenu.choiceMenu();
Scanner in=new Scanner(System.in);
int choice=in.nextInt();
switch (choice)
{
case 1:
choicemenu.choice1();
break;
case 2:
choicemenu.choice2();
break;
case 3:
choicemenu.choice3();
break;
case 4:
choicemenu.choice4();
break;
default:System.out.println("Please input the number bewteen 1 and 4.");
}
System.out.println("Come back to the Choice-Menu(Y/N)?");
input=in.next();
if(input.equals("N")||input.equals("Y"))
{
if(input.equals("N"))
{
System.out.println("Thinks for your use!");
System.exit(0);
}
}
else
{
System.out.println("You have a wrong choice!");
System.out.println("Please input your choice again!(Y/N)");
}
}
while(input.equals("Y"));
}
}
/**
* The TaxPayer is the user of the system.
* TaxPayer just have one field, that is
* the salary of the TaxPayer.
*/
class TaxPayer
{
private double salary;
public TaxPayer()
{
salary=0;
}
/**
* get the salary.
* @return salary
*/
public double getSalary()
{
return salary;
}
/**
* set the salary.
* @param the salary
*/
public void setSalary(double s)
{
salary=s;
}
}
/**
* TaxList has the methods of get/change the taxpoint
* and the taxrate. Also, you can calculate the tax by
* it.
*/
class TaxList
{
private double taxpoint;
private double[] taxrate=new double[5];
public TaxList(double p,double t0,double t1,double t2,double t3,double t4)
{
taxpoint=p;
taxrate[0]=t0;
taxrate[1]=t1;
taxrate[2]=t2;
taxrate[3]=t3;
taxrate[4]=t4;
}
/**
* get the taxpoint.
* @return taxpoint
*/
public double getTaxpoint()
{
return taxpoint;
}
/**
* set the taxpoint.
* @param the taxpoint
*/
public void setTaxpoint(double n)
{
taxpoint=n;
}
/**
* get the taxrate.
* @param the level of the tax
* @return the taxrate of the level
*/
public double getTaxrate(int n)
{
return taxrate[n];
}
/**
* set the taxrate.
* @param the level of the tax
* @param the raxrate of the level
*/
public void setTaxrate(int n,double r)
{
taxrate[n]=r;
}
/**
* calculate the tax.
* @param the salary
* @return the tax need to pay
*/
public double calculate(double s)
{
double taxsalary=s-taxpoint;
double tax;
if(taxsalary>20000)
{
tax=(taxsalary-20000)*0.25+3625;
return tax;
}
if(taxsalary>5000)
{
tax=(taxsalary-5000)*0.2+625;
return tax;
}
if(taxsalary>2000)
{
tax=(taxsalary-2000)*0.15+175;
return tax;
}
if(taxsalary>500)
{
tax=(taxsalary-500)*0.1+25;
return tax;
}
tax=taxsalary*0.05;
return tax;
}
}
/**
* Menu has the content of the taxmenu. Also, it has
* the choices and the tips that need to show to the
* user.
*/
class Menu
{
private String input="Y";
Scanner in=new Scanner(System.in);
TaxList list=new TaxList(1600,0.05,0.10,0.15,0.20,0.25);
TaxPayer person=new TaxPayer();
/**
* output the choice menu
*/
public void choiceMenu()
{
System.out.println("*********************************************************************");
System.out.println(" Welcome to use this tax-calculate system!");
System.out.println("");
System.out.println(" 1:Change your taxpoint.");
System.out.println(" 2:Change your taxrate.");
System.out.println(" 3:Calculate your tax.");
System.out.println(" 4:Exit.");
System.out.println("");
System.out.println(" Please input your choice:");
System.out.println("*********************************************************************");
}
/**
* the content of the choice1.
*@throws the wront information that input
* the system.
*/
public void choice1()
{
System.out.println("Now,the taxpoint is"+list.getTaxpoint());
System.out.println("Do you need change the taxpoint(Y/N)?");
do
{
input=in.next();
if(input.equals("N")||input.equals("Y"))
{
if(input.equals("Y"))
{
System.out.println("Please input your new taxpoint.");
list.setTaxpoint(in.nextDouble());
}
break;
}
else
{
System.out.println("You have a wrong choice!");
System.out.println("Do you need change the taxpoint(Y/N)?");
}
}
while(true);
}
/**
* the content of the choice2.
*@throws the wront information that input
* the system.
*/
public void choice2()
{
System.out.println("Now,the taxrate is:");
System.out.println("Level one:"+list.getTaxrate(0));
System.out.println("Level two:"+list.getTaxrate(1));
System.out.println("Level three:"+list.getTaxrate(2));
System.out.println("Level four:"+list.getTaxrate(3));
System.out.println("Level five:"+list.getTaxrate(4));
System.out.println("Do you need change the taxrate(Y/N)?");
do
{
input=in.next();
if(input.equals("N")||input.equals("Y"))
{
if(input.equals("Y"))
{
System.out.println("Please input you new taxrate.");
System.out.println("Level one:");
list.setTaxrate(0,in.nextDouble());
System.out.println("Level two:");
list.setTaxrate(1,in.nextDouble());
System.out.println("Level three:");
list.setTaxrate(2,in.nextDouble());
System.out.println("Level four:");
list.setTaxrate(3,in.nextDouble());
System.out.println("Level five:");
list.setTaxrate(4,in.nextDouble());
}
break;
}
else
{
System.out.println("You have a wrong choice!");
System.out.println("Please input your choice again!(Y/N)");
}
}
while(true);
}
/**
* the content of the choice3.
*@throws the wront information that input
* the system.
*/
public void choice3()
{
double salary;
do
{
System.out.println("Please input your salary:");
salary=in.nextDouble();
if(salary>=0)
{
person.setSalary(salary);
System.out.println("Your salary is:"+person.getSalary());
System.out.println("Your tax is:"+list.calculate(salary));
break;
}
else
{
System.out.println("Please input the number above 0.");
}
}
while(true);
}
/**
* the content of the choice4.
* get out of the system.
*/
public void choice4()
{
System.out.println("This system come from Deng He!");
System.out.println("Thinks for your use!");
System.exit(0);
}
}
个人所得税计算(JAVA源码)
5星 · 超过95%的资源 需积分: 50 65 浏览量
2008-12-23
16:54:24
上传
评论
收藏 2KB RAR 举报
is03dh
- 粉丝: 0
- 资源: 1
最新资源
- 基于CM9M0A5+TM1621C驱动设计LCD液晶屏模块ALTIUM硬件(原理图+PCB+封装库)工程文件.zip
- PCT7.C
- 基于SSM的“环卫工管理平台”的设计与实现.zip
- 基于SSM的“医院院内物资管理系统”的设计与实现.zip
- 毕设项目-基于同态加密的联邦学习安全聚合系统python源代码(高分).zip
- 基于同态加密的联邦学习安全聚合系统源码+项目说明(高分项目).zip
- 基于卷积神经网络算法识别猫狗图片项目源码+文档说明(高分大作业).zip
- 处理数据的界面,使用pyqt+pandas开发da-console-tool-master.zip
- pandas 使用笔记study-pandas-master.zip
- 基于matlab的薛定谔方程数值计算应用源码(下载即用).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论6