Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
May 8, 2020 02:20 pm GMT

Daily Challenge 239 - Graceful Tipping

Adding tip to a restaurant bill in a graceful way can be tricky, that's why you need make a function for it. The function will receive the restaurant bill (always a positive number) as an argument.

You need to:
1) add at least 15% in tip
2) round that number up to an elegant value and
3) return it.

What is an elegant number? It depends on the magnitude of the number to be rounded. Numbers below 10 should simply be rounded to whole numbers. Numbers 10 and above should be rounded like this:
10 - 99.99... ---> Round to number divisible by 5
100 - 999.99... ---> Round to number divisible by 50
1000 - 9999.99... ---> Round to number divisible by 500
And so on...

Examples
1 --> 2
7 --> 9
12 --> 15
86 --> 100

Tests
99 -->
114 -->
1149 -->

Good luck!

This challenge comes from viktorostlund on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!

Want to propose a challenge idea for a future post? Email [email protected] with your suggestions!


Original Link: https://dev.to/thepracticaldev/daily-challenge-239-graceful-tipping-1p69

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To