I'm trying to write a function that will tell me how many more is needed to reach a certain percentage.
This is the function I've gotten so far:
private static int CalculateHowManyNeeded(int TotalPallets, int PalletsDelivered, int MinReqPercentage = 25)
{
return Convert.ToInt32((MinReqPercentage / 100.00 * TotalPallets) - PalletsDelivered);
}
However, my method fails to give me the right answer if I have TotalPallets = 2, and palletsDelivered = 0. I'm expecting to get 1.. but my method returns 0...
What is the best way I can fix this problem?