Hi All ,how do i round up  this to 2 decimals:
 public override double GetPaymentAmount()
        {
           double paymentAmount = (WeeklySalary * 52 / 12);

           return paymentAmount;

        }

Recommended Answers

All 3 Replies

Try this.
Math.Round(paymentAmount , 2);

Basing off assumption as I wish on no one a negative weekly salary... and "round up"...

Multiply by 100 to shift 2 dicimal places. Call math.ceiling to 'round up' then devide by 100 to anti-shift 2 decimal places. You will then be left with a number that has been rounded up with 2 decimal places.

return Math.Ceiling(paymentAmount * 100) / 100;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.