//Diego Martinez CSC5 Chapter 3, P. 147,#18
/*******************************************************************************
* Sizing pizza pies
* ______________________________________________________________________________
* This program a program to calculate the number of slices a pizza of any size
* can be divided into.
*
* Computation is based on the Formula:
* radius = diameter / 2
* Area = π × r²
* numberOfSlices = pizzaArea / 14.125
*______________________________________________________________________________
* INPUT
* The user enters the diameter of the pizza.
*
* OUTPUT
* Displays how many slices the pizza can make.
*******************************************************************************/
#include <iostream>
#include <cmath>
using namespace std;
int main() {
const double PI = 3.14159;
const double SLICE_AREA = 14.125; // area of one slice in square inches
double diameter, radius, pizzaArea;
int numberOfSlices;
// A) Ask the user for the diameter
cout << "Enter the diameter of the pizza in inches: ";
cin >> diameter;
// Calculate radius
radius = diameter / 2;
// Calculate area of pizza
pizzaArea = PI * pow(radius, 2);
// B) Calculate number of slices
numberOfSlices = pizzaArea / SLICE_AREA;
// C) Display result
cout << "A pizza with a diameter of " << diameter
<< " inches can be divided into "
<< numberOfSlices << " slices." << endl;
return 0;
}