-4

My C# program requires two numerical outputs. A main price will be divided by 20% and 10%.

For example: Main price = 200 Discounted price: 20% of 200 = 40. Therefore total price is now 160.

I am having issues converting decimals, int's, etc. Here is what I have tried.

int discountNumber = 20 / 100;
decimal DiscountedPrice = Convert.ToInt32(TotalPrice)
                          / Convert.ToInt32(discountNumber);
txtTotalPrice.Text = DiscountedPrice.ToString();

2 Answers2

0

The problem in the

  int discountNumber = 20 / 100;

it's always zero

Dmitry Bychenko
  • 180,369
  • 20
  • 160
  • 215
-1

change the int to a double. 20/100 will give you a decimal figure not an int

user3437235
  • 92
  • 3
  • 9