vendredi 3 juillet 2020

How do I best write the tax bracket and income as variables to be calculated within the code?

I've attempted this many times and seem to just be spinning my wheels. How do I properly write the tax bracket and amount as variables that people could input different income amounts and it do the calculation in the code rather than just writing it out like I did here in the code?

    private void btnCalculate_Click(object sender, EventArgs e)
    {

Blockquote

        //variables
        int income = Convert.ToInt32 (txtIncome.Text);
        string status = (txtStatus.Text);
                    
        //determine tax bracket and ammount
        if(status == "single" && income <= 9275 || status == "married" && income <= 18550)
         {
            MessageBox.Show("tax bracket is .10 and taxes are $800 ");    
         }
        if(status == "single" && income >= 9276 && income <= 37650 || status == "married" && income 
          >= 18551 && income <= 75300)
        {
            MessageBox.Show("tax bracket is .15 with $3,000 owed in taxes");
        }
        if(status == "single" && income >= 37651 && income <= 91150 || status == "married" && income 
          >= 75301 && income <= 151900)
        {
            MessageBox.Show("tax bracket is .25 with 20000 owed in taxes");
        }
        if(status == "single" && income >=91151 && income <= 190150 || status == "married" && income 
            >= 151901 && income <= 231450)
        {
            MessageBox.Show("tax bracket is .28 with $42,532.28 in taxes");
        }
        if (status == "single" && income >= 190151 && income <= 413350 || status == "married" && 
          income >= 231451 && income <= 413350)
        {
            MessageBox.Show("tax bracket is .33 with $82500 in taxes");
        }
        if(status == "single" && income >= 413351 && income <= 415050 || status == "married" && 
            income >= 413351 && income <= 466950)
        {
            MessageBox.Show("tax bracket is .35 with taxes of $144,672.85");
        }
        else
            MessageBox.Show("tax bracket is 39.6% with taxes of ")
       

    

Aucun commentaire:

Enregistrer un commentaire