ApexSensei

Drills Apex basics

Money is a Decimal

Salesforce currency is a Decimal.

Your task

Round Opportunity tax and total with HALF_UP, then round the same tie two different ways.

Decimal amount = 249.50;
Decimal taxRate = 0.08;

Decimal tieAmount = 1.225;

Requirements

  1. setScale(2, should be present
  2. RoundingMode.HALF_UP should be present
  3. Amount: 249.50 should be printed
  4. Tax: 19.96 should be printed
  5. Total: 269.46 should be printed
  6. HALF_UP tie: 1.23 should be printed
  7. Default tie: 1.22 should be printed

Sign in to open this drill