1

So I need to get a quotient to 2 decimal places like 0.33, but do I need to use doubles all the way down or can I use integers for everything except the quotient and then just use double or decimal for the quotient? It is also breaking because of the quotient. If anyone could help me I would be extremely grateful :)

int firstnumber;
        int secondnumber;
        decimal quotient;

        firstnumber = int.Parse(inputTextBox1.Text);
        secondnumber = int.Parse(inputTextBox2.Text);

        sumLabel.Text = (firstnumber + secondnumber).ToString();

        differenceLabel.Text = (firstnumber - secondnumber).ToString();

        productLabel.Text = (firstnumber * secondnumber).ToString();

        quotient = decimal.Parse(quotientLabel.Text);
        quotient = (firstnumber / secondnumber).tostring;
user2884461
  • 109
  • 1
  • 2
  • 9

1 Answers1

6

You can cast the integers to decimal or double when assigning your variable, then assign the label from the results:

quotient = ((decimal)firstnumber / secondnumber);
quotientLabel.Text = quotient.ToString("N2");
Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373