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:

CreatedMay 6, 2020
PublishedMay 6, 2020
Warriors Trained3715
Total Skips93
Total Code Submissions13651
Total Times Completed1497
JavaScript Completions645
TypeScript Completions91
Python Completions652
C Completions78
Ruby Completions92
Haxe Completions14
Total Stars46
% of votes with a positive feedback rating88% of 309
Total "Very Satisfied" Votes245
Total "Somewhat Satisfied" Votes54
Total "Not Satisfied" Votes10
Total Rank Assessments6
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • viktorostlund Avatar
  • anter69 Avatar
  • Blind4Basics Avatar
  • rowcased Avatar
  • user8436785 Avatar
  • constnw Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad