# Code.org principles Unit 7 Lesson 3 dot 6 Rounding total with tax

**URL:** <https://forum.code.org/t/code-org-principles-unit-7-lesson-3-dot-6-rounding-total-with-tax/35835>\
**Category:** Coding and Debugging Help\
**Created:** [February 7, 2022, 9:34pm UTC](https://forum.code.org/t/code-org-principles-unit-7-lesson-3-dot-6-rounding-total-with-tax/35835 "2022-02-07T21:34:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlynch](https://avatars.discourse-cdn.com/v4/letter/r/58f4c7/32.png) [@rlynch](https://forum.code.org/u/rlynch)\
**Post date:** [February 7, 2022, 9:34pm UTC](https://forum.code.org/t/code-org-principles-unit-7-lesson-3-dot-6-rounding-total-with-tax/35835/1 "2022-02-07T21:34:07Z")

</div>

**[My students and I are trying to round the answer with tax to display the dollar and cents .]**

**Link to the project or level:** [([Code.org](https://studio.code.org/s/csp7-2021/lessons/3/levels/6?section_id=3495390))]]([Code.org](https://studio.code.org/s/csp7-2021/lessons/3/levels/6?section_id=3495390))]  
**What I expect to happen:** [display should round to the nearest 100th then add that to the total]  
**What actually happens:** [through various iterations we have gotten the tax to display but it won’t add back to the original amount]  
**What I’ve tried:** [function totalWithTax(amount){  
var total = (amount\*0.07/100)+total;  
return total;  
}]

---

<div class="post-metadata">

**Author:** ![bhatnagars](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/bhatnagars/32/4919_2.png) [@bhatnagars](https://forum.code.org/u/bhatnagars)\
**Post date:** [February 7, 2022, 10:10pm UTC](https://forum.code.org/t/code-org-principles-unit-7-lesson-3-dot-6-rounding-total-with-tax/35835/2 "2022-02-07T22:10:46Z")

</div>

`Math.round` function can be used for rounding in the `totalWithTax` function.

1. Calculate the amount with tax: `total = amount + amount * 0.07`
2. Multiply the amount with tax by 100 and use `Math.round ` on the result: `total = Math.round(total*100)` to remove all the extra decimal values.
3. Divide by 100 to get 2 decimal places: `total = total /100`
4. Return total

---

<div class="post-metadata">

**Author:** ![rlynch](https://avatars.discourse-cdn.com/v4/letter/r/58f4c7/32.png) [@rlynch](https://forum.code.org/u/rlynch)\
**Post date:** [February 7, 2022, 10:26pm UTC](https://forum.code.org/t/code-org-principles-unit-7-lesson-3-dot-6-rounding-total-with-tax/35835/3 "2022-02-07T22:26:53Z")

</div>

perfection thank you so much it was a fun thought experiment but we were all getting frustrated by the end. Thank you again!
