string input = Console.ReadLine();
decimal sum = Convert.ToDecimal(input);
if (sum >= (decimal)500.01)
{
//40% and 8 dollars off shipping costs are taken off total amount
decimal totalprice;
totalprice = (sum - 8) * .60m;
Math.Truncate(totalprice);
Console.WriteLine("Your final cost is:${0:0.00}", totalprice);
Console.Read();
The problem is, when I enter the price 598.88 dollars into my program, I should get 354.52.
The Math:
598.88 - 8 = 590.88. 590.88 * 60% = 354.528
I actually get 354.53
because C# rounds up instead of down.
For example,
If I get an answer like 519.998
, I want it to STAY at 519.99
.
Another example, if I get an answer like 930.755
I want it to stay at 930.75
.
I looked into some answers, but Math.Truncate
obviously doesn't work for me and using the *100 / 100
trick didn't work either. Keep in mind I'm a new student, So, if an answer could be noob-safe, that would be nice. Thanks.