Jump to content

What is wrong with my c# visual studio coding?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
reja

reja

    Newbie

  • Members
  • PipPip
  • 12 posts
this program is supposed to determine/calculate the tax that a person has to pay based on his taxable income.
I did some c# coding using visual studio.I keep getting errors.anyone knows the right way to do it?

my codes:

private void calculateTaxBTN_Click(object sender, EventArgs e)
{
double taxableIncome;
taxableIncome = Convert.ToDouble(userValueTB);
double tax;
tax = 0;
if (taxableIncome <= 38000)
{
tax = 0.195 * 3800;
}
if (taxableIncome > 3800 && taxableIncome <= 60000)
{
tax = 0.195 * 3800 + 0.33 * 22000;
}
if (taxableIncome > 60000)
{
tax = 0.195 * 38000 + 0.33 * 22000 + 0.39 * taxableIncome - 60000;
}
double displayLabel;
displayLabel = Convert.ToDouble(displayLabel.Text);

#2
BuckAMayzing

BuckAMayzing

    Learning Programmer

  • Members
  • PipPipPip
  • 39 posts
There's never a closing brace for the method for starters.

Secondly, displayLabel is declared as a double. What you want to do, provided you have a label called displayLabel is something like this:

diplayLabel.Text = tax.toString();


also, I'm not sure what userValueTB is at all.

#3
reja

reja

    Newbie

  • Members
  • PipPip
  • 12 posts
userValueTb is the name given to the text box that i created in the GUI design....p.s thanks for helping

#4
BuckAMayzing

BuckAMayzing

    Learning Programmer

  • Members
  • PipPipPip
  • 39 posts
Sure thing.