用C#控台应用程序编写一个计算个人所得税的程序,具体要求如下,谢谢

用C#控台应用程序编写一个计算个人所得税的程序,具体要求如下,谢谢,第1张

decimal CalTax(decimal totalIncome)

{

decimal tax, income;

if(totalIncome <= 1600)

tax = 0;

else

{

income = totalIncome - 1600;

if(income <= 500)

tax = income 005;

else

if(income <= 2000)

tax = 500 005 + (income - 500) 01;

else

if(income <= 5000)

tax = 500 005 + 1500 01 + (income - 2000) 015;

else

if(income <= 20000)

tax = 500 005 + 1500 01 + 3000 015 + (income - 5000) 02;

else

//以下类似

}

return tax;

}

我百度到的……

#include <stdioh>

#define TAXBASE 2000

typedef struct{

long base;

long limit;

double taxrate;

}TAXTABLE;

TAXTABLE TaxTable[] = {\

{0, 500, 005},\

{500, 2000, 010},\

{2000, 5000, 015},\

{5000, 20000, 020},\

{20000, 40000, 025},\

{40000, 60000, 030},\

{60000, 80000, 035},\

{80000, 100000, 040},\

{100000,1e10, 045},\

};

double CaculateTax(long profit)

{

int i;

double tax = 00;

profit -= TAXBASE;

for(i=0; i< sizeof(TaxTable)/sizeof(TAXTABLE); i++)

{

if( profit > TaxTable[i]base )

{

if( profit > TaxTable[i]limit )

{

tax += (TaxTable[i]limit - TaxTable[i]base) TaxTable[i]taxrate;

}

else

{

tax += (profit - TaxTable[i]base) TaxTable[i]taxrate;

}

profit -= TaxTable[i]limit;

printf("Base%d:%6ld Limit%d:%6ld Tax:%122f Leave:%6ld\n",i,TaxTable[i]base,i,\

TaxTable[i]limit, tax, (profit)>0 profit : 0);

}

}

return tax;

}

int main(void)

{

long profit;

double tax;

printf("Please enter your profit:");

scanf("%ld",&profit);

tax = CaculateTax(profit);

printf("Tax is: %122f\n",tax);

return 0;

}

Java编的

import javaio;

import orgeclipseswtwidgets;

import orgeclipseswtwidgetsButton;

import orgeclipseswtwidgetsText;

import orgeclipseswtwidgetsLabel;

import orgeclipseswtwidgetsShell;

public class incomingtax {

private Shell sShell = null; // 创建各类可视化组件

private Button button = null;

private Text text = null;

private Label label = null;

private Text textArea = null;

private Label label1 = null;

private Button button1 = null;

private Text textArea1 = null;

private Label label2 = null;

private Label label3 = null;

private static final String NEW_LINE = SystemgetProperty("lineseparator"); //静态的String,字符分割

private boolean hasChanged = false; //定义一个boolean变量,当文本被更改时为ture

private void createSShell() { //创建窗体及定义各种方法

sShell = new Shell(SWTBORDER | SWTSHELL_TRIM | SWTPRIMARY_MODAL);

button = new Button(sShell, SWTNONE);

text = new Text(sShell, SWTBORDER);

label = new Label(sShell, SWTCENTER);

textArea = new Text(sShell, SWTMULTI | SWTWRAP | SWTV_SCROLL | SWTBORDER);

label1 = new Label(sShell, SWTCENTER);

button1 = new Button(sShell, SWTNONE);

textArea1 = new Text(sShell, SWTMULTI | SWTWRAP | SWTV_SCROLL | SWTBORDER);

label2 = new Label(sShell, SWTCENTER);

label3 = new Label(sShell, SWTCENTER);

buttonsetBounds(new orgeclipseswtgraphicsRectangle(232,153,54,35));

buttonsetText("Open");

textsetBounds(new orgeclipseswtgraphicsRectangle(223,80,72,20));

labelsetBounds(new orgeclipseswtgraphicsRectangle(203,45,110,26));

labelsetText("TAX FREE");

textAreasetBounds(new orgeclipseswtgraphicsRectangle(5,39,169,341));

label1setBounds(new orgeclipseswtgraphicsRectangle(347,4,119,15));

label1setText("TAXABLE INCOME");

button1setBounds(new orgeclipseswtgraphicsRectangle(231,215,51,35));

button1setText("Save");

textArea1setBounds(new orgeclipseswtgraphicsRectangle(328,39,171,335));

label2setBounds(new orgeclipseswtgraphicsRectangle(23,5,130,14));

label2setText("INCOME TAX");

sShellsetText("NEGATIVE INCOME TAX");

sShellsetMinimized(false);

sShellsetMaximized(false);

label3setBounds(new orgeclipseswtgraphicsRectangle(178,354,146,17));

label3setText("MADE BY YANGKUN");

sShellsetSize(new orgeclipseswtgraphicsPoint(512,417));

button

addSelectionListener(new orgeclipseswteventsSelectionAdapter() {

public void widgetSelected(

orgeclipseswteventsSelectionEvent e) {

loadFile(); //监听button的单击事件,当单击时,调用loadFile()方法

}

});

button1

addSelectionListener(new orgeclipseswteventsSelectionAdapter() {

public void widgetSelected(

orgeclipseswteventsSelectionEvent e) {

saveFile(); //监听button1的单击事件,当单击时,调用saveFile()方法

}

});

}

public static void main(String[] args) {

//要运行SWT,必须在VM中设置

// -Djavalibrarypath="installation_directory\plugins\orgeclipseswtwin32_301\os\win32\x86"

orgeclipseswtwidgetsDisplay display = orgeclipseswtwidgetsDisplaygetDefault();

incomingtax test = new incomingtax();

testcreateSShell() ;

testsShellopen();

while (!testsShellisDisposed()) {

if (!displayreadAndDispatch()) displaysleep ();

}

displaydispose();

}

private void loadFile(){

FileDialog dialog = new FileDialog(sShell, SWTOPEN); //创建一个打开的对话框

String result = dialogopen(); //将要打开的文件路径,赋值给String变量 result

if (result != null) {

File f = new File(result);

double shuie = 0;

double jine = 0;

double jianfye = DoubleparseDouble(textgetText()); //从text组件中,获取文本

try {

BufferedReader br = new BufferedReader(new FileReader(f)); //开启缓存给打开文件

StringBuffer buff = new StringBuffer(); //建立新的流缓存br

String line = brreadLine(); //当br读一行文本时,赋值给line

String out = new String(); //创建空String,out

String out2 = out;

while (line != null) { //line不为null的时候,一直循环

shuie = DoubleparseDouble(line); //line的值,转换为double进行运算

if(shuie>29625){

jine = (shuie+15375)/045+jianfye;

}else if(shuie>21625){

jine = (shuie+10375)/04+jianfye;

}else if(shuie>14625){

jine = (shuie+6375)/035+jianfye;

}else if(shuie>8625){

jine = (shuie+3625)/03+jianfye;

}else if(shuie>3625){

jine = (shuie+1375)/025+jianfye;

}else if(shuie>625){

jine = (shuie+375)/02+jianfye;

}else if(shuie>175){

jine = (shuie+125)/015+jianfye;

}else if(shuie>25){

jine = (shuie+25)/01+jianfye;

}else{

jine = shuie/005+jianfye;

}

out = StringvalueOf(jine); //变量jine,以String的形式赋值给out

out2=out2+"\n"+out; //进行String累加

buffappend(line + NEW_LINE); //已读取的文本加换行线

line = brreadLine(); //继续读下一行

}

textAreasetText(bufftoString()); //将buff变量流化后,赋值给容器textArea

textArea1setText(out2);

brclose(); //关闭br

hasChanged = false; //进行是否更改判断

} catch (FileNotFoundException e1) { //抛出异常的处理

e1printStackTrace();

} catch (IOException e1) {

e1printStackTrace();

}

}

}

private void saveFile() {

FileDialog dialog = new FileDialog(sShell, SWTSAVE); //创建一个保存对话框

String result = dialogopen(); //将保存的路径赋值给result

if (result != null) {

File f = new File(result);

try {

BufferedWriter bw = new BufferedWriter(new FileWriter(f)); //开启写文件流

String text = textArea1getText(); //将容器textArea中的文本赋值给String值text

bwwrite(text); //将text中的值写入文本

bwclose(); //关系bw通道

hasChanged = false; //是否更改判断

} catch (FileNotFoundException e1) { //抛出异常的处理

e1printStackTrace();

} catch (IOException e1) {

e1printStackTrace();

}

}

}

}

以上就是关于用C#控台应用程序编写一个计算个人所得税的程序,具体要求如下,谢谢全部的内容,包括:用C#控台应用程序编写一个计算个人所得税的程序,具体要求如下,谢谢、编写计算个人所得税的c语言源程序代码及流程图、如何设计一个计算个人所得税的程序(不用太难得哦)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/9345311.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-27
下一篇 2023-04-27

发表评论

登录后才能评论

评论列表(0条)

保存