// Renee V. Lopez CS1A Chapter 3 P.146 #17
/******************************************************************************
* Calculate Pizza Slices
* _____________________________________________________________________________
* This program calculates the number of slices a pizza can be divided into,
* based on its diameter. Each slice should have an area of 14.125 square inches.
*
* _____________________________________________________________________________
* INPUT
* diameter : The diameter of the pizza in inches
* _____________________________________________________________________________
* OUTPUT
* slices : Number of slices the pizza can be divided into
* ****************************************************************************/
#include <iostream>
#include <iomanip> // For setting output precision
using namespace std;
int main() {
// Define constants
const double PI = 3.14159; // Named constant for PI
const double SLICE_AREA = 14.125; // Area of each pizza slice in square inches
// Declare variables
double diameter; // Diameter of the pizza
double radius; // Radius of the pizza
double area; // Area of the pizza
double slices; // Number of slices
// Prompt user for diameter of the pizza
cout << "Enter the diameter of the pizza in inches: ";
cin >> diameter;
// Calculate the radius of the pizza
radius = diameter / 2.0;
// Calculate the area of the pizza
area = PI * radius * radius;
// Calculate the number of slices
slices = area / SLICE_AREA;
// Display the number of slices, rounded to one decimal place
cout << fixed << setprecision(1);
cout << "Number of slices: " << slices << endl;
return 0;
}