You have a number of pizza slice shops in your town and you want to write a webapp that will let you compare two different pizza configurations to let you know who will give you the bigger slice.
Implement the function, sliceSize(diameter: Double?, slices: Int?) -> Double?, which, given the diameter of a pizza and the number of slices per pizza returns the area of a slice.
For negative diameters and for number of slices less than 1, return nil, as there is no such thing as a pizza with negative diameter and no way to slice a pizza into fewer than 1 slice.
If either parameter is nil, also return nil
sliceSize(diameter: 16, slices: 12)
// Returns 16.75516081914556
sliceSize(diameter: nil, slices: 8)
// Returns nilYou web application will pass four strings to your function, biggestSlice(diameterA: String, slicesA: String, diameterB: String, slicesB: String) -> String.
The first and second strings are the diameter and number of slices of the first pizza respectively, and the third and fourth are the diameter and number of slices of the second pizza respectively.
Implement biggestSlice so that it attempts to convert the diameter and number of slices for each pizza into a Double and an Int respectively.
If both of these values can be obtained from the strings, use your first function to try to compute the area, otherwise the area for that slice is nil.
Once the areas of both slices are obtained, compare the two areas using the following rules:
Double and slice B's is nil, return "Slice A is bigger". If the reverse is true, return "Slice B is bigger".Doubles, return "Slice A is bigger" or "Slice B is bigger" according to which slice has the greater area.nil, or if both are Doubles and they are equal, return "Neither slice is bigger".Even if the input result in a slice area of 0, the slice is still considered valid, and should be seen as bigger than a slice with an area of nil.
biggestSlice(diameterA: "10", slicesA: "6", diameterB: "14", slicesB: "12")
// Returns "Slice A is bigger"
biggestSlice(diameterA: "10", slicesA: "6", diameterB: "12", slicesB: "8")
// Returns "Slice B is bigger"
biggestSlice(diameterA: "Pepperoni", slicesA: "6", diameterB: "Sausage", slicesB: "12")
// Returns "Neither slice is bigger"You have a number of pizza slice shops in your town and you want to write a webapp that will let you compare two different pizza configurations to let you know who will give you the bigger slice.
Implement the function, sliceSize(diameter: Double?, slices: Int?) -> Double?, which, given the diameter of a pizza and the number of slices per pizza returns the area of a slice.
For negative diameters and for number of slices less than 1, return nil, as there is no such thing as a pizza with negative diameter and no way to slice a pizza into fewer than 1 slice.
If either parameter is nil, also return nil
sliceSize(diameter: 16, slices: 12)
// Returns 16.75516081914556
sliceSize(diameter: nil, slices: 8)
// Returns nilYou web application will pass four strings to your function, biggestSlice(diameterA: String, slicesA: String, diameterB: String, slicesB: String) -> String.
The first and second strings are the diameter and number of slices of the first pizza respectively, and the third and fourth are the diameter and number of slices of the second pizza respectively.
Implement biggestSlice so that it attempts to convert the diameter and number of slices for each pizza into a Double and an Int respectively.
If both of these values can be obtained from the strings, use your first function to try to compute the area, otherwise the area for that slice is nil.
Once the areas of both slices are obtained, compare the two areas using the following rules:
Double and slice B's is nil, return "Slice A is bigger". If the reverse is true, return "Slice B is bigger".Doubles, return "Slice A is bigger" or "Slice B is bigger" according to which slice has the greater area.nil, or if both are Doubles and they are equal, return "Neither slice is bigger".Even if the input result in a slice area of 0, the slice is still considered valid, and should be seen as bigger than a slice with an area of nil.
biggestSlice(diameterA: "10", slicesA: "6", diameterB: "14", slicesB: "12")
// Returns "Slice A is bigger"
biggestSlice(diameterA: "10", slicesA: "6", diameterB: "12", slicesB: "8")
// Returns "Slice B is bigger"
biggestSlice(diameterA: "Pepperoni", slicesA: "6", diameterB: "Sausage", slicesB: "12")
// Returns "Neither slice is bigger"