I'm got write a simple calculation. which only use % and / .but when i key in different number. the result is different.Who can help me.
private void button1_Click(object sender, EventArgs e)
{
decimal x = txtPer.Value;
decimal y = txtQty.Value;
decimal j= y / x;
decimal k = y % x;
txtPack.Value = j;
txtRemain.Value = k;
}
From the picture, we can see that 10/3=3 and 10%3=1 is right.
But I key in 5/2=3 5%2=1 is wrong. It should be 5/2=2.
If 5/2=3 5%2=1,we multiply and plus back will become 2*3+1=7. The answer is wrong