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
public class Kata
{
  public static double PizzaPriceCheck(object diameter, object price)
  {
     // ... your code
  }
}

Kata.PizzaPriceCheck(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

Stats:

CreatedApr 5, 2017
PublishedApr 5, 2017
Warriors Trained705
Total Skips13
Total Code Submissions2727
Total Times Completed419
JavaScript Completions351
C# Completions76
Total Stars10
% of votes with a positive feedback rating87% of 141
Total "Very Satisfied" Votes109
Total "Somewhat Satisfied" Votes27
Total "Not Satisfied" Votes5
Total Rank Assessments13
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • saifahn Avatar
  • JohanWiltink Avatar
  • Souzooka Avatar
  • hobovsky Avatar
Ad