Home > Net >  Personal tax calculator. C # programming and don't get what they want the answer, go ah...
Personal tax calculator. C # programming and don't get what they want the answer, go ah...

Time:11-23

Using System;
using System.Collections.Generic;
Using System.Com ponentModel;
Using System. The Data;
Using System. Drawing;
Using System. Linq;
Using System. The Text;
Using System. Windows. Forms;

The namespace rate calculator 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 _click ()
{
InitializeComponent ();
}

Private void btnQuit_Click (object sender, EventArgs e)
{
Enclosing the Close ();
}

Private void btnOk_Click (object sender, EventArgs e)
{
Try
{
Int [] a; Double [] b; Int [] c;
A=new int [] {00 0150 0450 0900 0350 00550 00800};
B=new double [] {0.3, 0.10, 0.20, 0.25, 0.30, 0.35, 0.45};
C=new int [] {0105555100}, 5275, 5550, 5135 05;
Int Q=0;
for (int i=0; I & lt; 7. I++)
{
[Q]. M_taxTable upperLimit=a, [I].
[Q]. M_taxTable TaxRate=b [I];
[Q]. M_taxTable deduction=c [I];
Q++;
}
Double income=the Convert. ToDouble (txtIncome. Text);
Double taxes=0;
If (income - m_dThreshold & gt; 0)
{
Foreach (TaxRecord theRecord in enclosing m_taxTable)
{
If (income & lt;=(theRecord upperLimit + m_dThreshold))
{
Taxes=(income - m_dThreshold) * theRecord TaxRate - theRecord. Deduction;
break;
}
}
}
Double incomeAfterTaxes=income taxes;
Enclosing txtIncomeAfterTaxes. Text=incomeAfterTaxes. ToString (" 0.00 ");
Enclosing txtTaxes. Text=taxes. ToString (" 0.00 ");
}
Catch {}
}

}
}

CodePudding user response:

A=new int [] {00 0150 0450 0900 0350 00550 00800};
The taxable income amount is according to the ascending order
Calculation to reverse

CodePudding user response:

A=new int [] {00 0150 0450 0900 0350 00550 00800};
B=new double [] {0,0.10, 0.20, 0.25, 0.30, 0.35, 0.45};
C=new int [] {0105555100}, 5275, 5550, 5135 05;
Wrong, the value of your array B
Should be as above value,

CodePudding user response:

A=new int [] {00 0150 0450 0900 0350 00550 00800};
B=new double [] {0.03, 0.10, 0.20, 0.25, 0.30, 0.35, 0.45};
C=new int [] {0105555100}, 5275, 5550, 5135 05;
Wrong, the value of your array B
Should be as above value, 0.03, you get a 0.3,

CodePudding user response:

Calculation according to the reverse is what meaning,,,

CodePudding user response:

80000
55000
35000
9000
4500
1500

CodePudding user response:

Still have to put the if (income & lt;=(theRecord upperLimit + m_dThreshold)) & lt;=change & gt;=, and combined with the above said descending order to be successful!

CodePudding user response:

refer to the second floor xuzuning response:
a=new int [] {00 0150 0450 0900 0350 00550 00800};
The taxable income amount is according to the ascending order
Calculation to reverse when

The idea is good, I also did this, is made of positive sequence, wrote a very troublesome algorithm
Using reverse to do is very simple,
  •  Tags:  
  • C#
  • Related