7 kyu
Frugal Pizza
351 of 419saifahn
Description:
You love pizza, but you also love getting bang for your buck. One thing that irks you when you go to your local pizza place is that although they list the diameter and price of each pizza, they don't list the cost per square inch. (Unbelievable, I know!)
Write a function that takes two arguments - diameter, in inches, and price - and returns the price per square inch to two decimal places. (as a number, not a string)
function pizzaPrice (diameter, price) {
// ... your code
}
pizzaPrice(7, 4.30) // should return 0.11
Assume that the pizza is a circular pizza of uniform diameter, and use Math.PI as the value of pi.
If you are given too few arguments, or if they aren't numbers, then return 0. In C# you will be given only numbers.
Fundamentals
Similar Kata:
Stats:
Created | Apr 5, 2017 |
Published | Apr 5, 2017 |
Warriors Trained | 705 |
Total Skips | 13 |
Total Code Submissions | 2727 |
Total Times Completed | 419 |
JavaScript Completions | 351 |
C# Completions | 76 |
Total Stars | 10 |
% of votes with a positive feedback rating | 87% of 141 |
Total "Very Satisfied" Votes | 109 |
Total "Somewhat Satisfied" Votes | 27 |
Total "Not Satisfied" Votes | 5 |
Total Rank Assessments | 13 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 8 kyu |