Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

private void btnCalculate_Click(object sender, EventArgs e) { //get the textbox income decimal income = Convert.ToDecimal(txtIncome.Text); //declare a variable for the tax decimal tax = 0m;

image text in transcribed

private void btnCalculate_Click(object sender, EventArgs e) { //get the textbox income decimal income = Convert.ToDecimal(txtIncome.Text); //declare a variable for the tax decimal tax = 0m; //tax value presented by calling the CalculateTax method. tax = CalculateTax(income); //display tax txtTax.Text = tax.ToString(); } //private method named CalculateTax that receives the income amount and returns the tax amount. private decimal CalculateTax(decimal income) { //declare a variable for the tax decimal tax = 0m; //calculate the tax owed based on income if (income 9875 && income 40126 && income 85526 && income 163301 && income 207351 && income 518400) tax = 156235m + (int)((income - 518400) * .37m); else MessageBox.Show("Invalid input format. Please check all entries");

//return the calculated tax amount return tax;

} //event handler that clears the Income Tax Owed text box if the user changes the value in the Taxable Income text box. private void txtTax_TextChanged(object sender, EventArgs e) { txtIncome.Text = ""; }

private void btnExit_Click(object sender, EventArgs e) { this.Close(); } } }

I keep getting this message when I input a number to calculate tax. Can you tell me what I did wrong?

Chegg - Word Kenneth King KK X File Edit View Git Project Build Debug Test Analyze Tools Extensions Window Help Search (Ctrl+Q) income TaxCalculator Debug Any CPU Continue E DE Live Share Income TaxCalculator.Designer.cs Income TaxCalculator.cs + x Income TaxCalculator.cs (Design) income_TaxCalculator.Income TaxCalculator Diagnostic Tools o PabtnCalculate_Click(object sender, EventArgs e) + C# income TaxCalculator 25 Solution Explorer Diagnostics session: 11 seconds (11.511 s selected) 1 reference private void btnCalculate_Click(object sender, EventArgs e) Events II 26 27 28 29 30 31 32 33 34 35 36 Process Memory (MB) 16 16 0 0 CPU (% of all processors) 100 100 //get the textbox income decimal income = Convert.ToDecimal(txtIncome.Text); X //declare a variable for the tax decimal tax = Om; Exception Unhandled //tax value presented by calling the CalculateTax me tax = CalculateTax(income); System.FormatException: 'Input string was not in a correct format.' //display tax This exception was originally thrown at this call stack: txtTax.Text = tax.ToString(); [External Code] } income_TaxCalculator.Income TaxCalculator.btnCalculate_Click(obje //priv method named CalculateTax that receives the in [External Code] 1 reference income_TaxCalculator.Program. Main() in Program.cs private decimal CalculateTax(decimal income) { View Details Copy Details Start Live Share session... //declare a variable for the tax Exception Settings decimal tax = m; Break when this exception type is thrown // calculate the tax owed based on income Except when thrown from: if (income

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions