Search code examples
c#.neteuro

c# Percentage calculator


I have little problem, and I need help..

So here is my problem I have created win form in c# and used numericupdown element to insert my numbers, but I cant calculate percent. Here is the code below:

private void button8_Click(object sender, EventArgs e)
    {
        int x, y, sum;
        x = Convert.ToInt16(numericUpDown7.Value);
        y = Convert.ToInt16(numericUpDown8.Value);
        sum = x * 3.4528 + 21%;
        textBox5.Text = Convert.ToString(sum);
    }

What I need to do is to insert x and press button to calculate this formula

example: x * 3.4528 + 21 % = ???

Maby someone has options to help me.

Thanks for all of you, who will help me!


Solution

  • Try this

    sum = (x * 3.4528) * 1.21;