Interest paid out every year
Each year you get the same amount: interest each year = amount × rate
$5,000 at 3.5% for 2 years: $5,000 × 0.035 = $175 a year, so $350 in total.
Compound interest (paid at the end)
The interest is added on every year: what you get back = amount × (1 + rate)years
$5,000 at 3.5% for 2 years: $5,000 × 1.035 × 1.035 = $5,356.13, so $356.13 of interest.
Rates are yearly. For a rate like 3.5%, use 0.035 in the formula.