7 kyu
Graceful Tipping
652 of 1,497viktorostlund
Description:
Adding tip to a restaurant bill in a graceful way can be tricky, thats 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...
Good luck!
Examples
1 --> 2
7 --> 9
12 --> 15
86 --> 100
Mathematics
Fundamentals
Similar Kata:
Stats:
Created | May 6, 2020 |
Published | May 6, 2020 |
Warriors Trained | 3715 |
Total Skips | 93 |
Total Code Submissions | 13651 |
Total Times Completed | 1497 |
JavaScript Completions | 645 |
TypeScript Completions | 91 |
Python Completions | 652 |
C Completions | 78 |
Ruby Completions | 92 |
Haxe Completions | 14 |
Total Stars | 46 |
% of votes with a positive feedback rating | 88% of 309 |
Total "Very Satisfied" Votes | 245 |
Total "Somewhat Satisfied" Votes | 54 |
Total "Not Satisfied" Votes | 10 |
Total Rank Assessments | 6 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |