using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 税率计算器Yal
{
public partial class Form1 : Form
{
struct TaxRecord
{
public double upperLimit;
public double TaxRate;
public double deduction;
}
private TaxRecord[] m_taxTable = new TaxRecord[7];
private const double m_dThreshold = 3500;
public Form1()
{
InitializeComponent();
}
private void btnQuit_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnOk_Click(object sender, EventArgs e)
{
try
{
int[] a; double[] b; int[] c;
a = new int[] {0,1500,4500,9000,35000,55000,80000};
b = new double[] {0.3,0.10,0.20,0.25,0.30,0.35,0.45};
c = new int[] {0,105,555,1005,2755,5505,13505};
int Q = 0;
for (int i = 0; i < 7; i++)
{
m_taxTable[Q].upperLimit = a[i];
m_taxTable[Q].TaxRate = b[i];
m_taxTable[Q].deduction = c[i];
Q++;
}
double income = Convert.ToDouble(txtIncome.Text);
double taxes = 0;
if (income - m_dThreshold > 0)
{
foreach (TaxRecord theRecord in this.m_taxTable)
{
if (income <= (theRecord.upperLimit + m_dThreshold))
{
taxes = (income - m_dThreshold) * theRecord.TaxRate - theRecord.deduction;
break;
}
}
}
double incomeAfterTaxes = income - taxes;
this.txtIncomeAfterTaxes.Text = incomeAfterTaxes.ToString("0.00");
this.txtTaxes.Text = taxes.ToString("0.00");
}
catch { }
}
}
}