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; decimal.TryParse(txtTax.Text, out income); //declare a variable for the tax decimal tax =

private void btnCalculate_Click(object sender, EventArgs e) {

//get the textbox income decimal income; decimal.TryParse(txtTax.Text, out income); //declare a variable for the tax decimal tax = 0m; //tax value presented by calling the CalculateTax method. tax = CalculateTax(income); //display tax txtIncome.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(); } } }

How can I make the message box work if the user inputs the wrong entry. I cant get it to work.

Like this

image text in transcribed

File Edit View Git Project Build Debug Test Analyze Tools Extensions Window Help Search (Ctrl+Q) income TaxCalculator Debug Any CPU Continue Income TaxCald Form 1 Income TaxCalculator.cs (Design) income TaxCalculator.Income TaxCalculator ncome

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

Students also viewed these Databases questions

Question

25.0 m C B A 52.0 m 65.0 m

Answered: 1 week ago