Divide into functions and Output to file

How do you divide this up into functions and output it to a file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;


int main()
{
    const double PI = 3.14159;

    int guests;
    double diameter;
    double radius;
    double area;
    double slices;

    cout << fixed << setprecision(2) << "What is the diameter of the pizza (in inches) desired? ";
    cin >> diameter;
    radius = diameter / 2.0;
    cout << endl;
    cout << fixed << setprecision(2) << "The radius of the pizza is " << radius << " inches." << endl;
    area = PI * pow(radius, 2.0);
    slices = floor(area / 14.125);
    cout << fixed << setprecision(2) << "The area of the pizza is: " << area << endl;
    cout << fixed << setprecision(0) << "The number of slices that this pizza can produce is: " << slices << " slices.\n"<< endl;
    cout << "How many guests will be attending the function? ";
    cin >> guests;
    cout << endl;
    cout << "If each guest eats an average of 4 slices, you will need "<< (guests * 4) << " slices.\n"<<endl;
    cout << "Therefore, "<< ceil(((guests * 4.0)/slices)) << " pizzas should be ordered." << endl;

    return 0;
}
Topic archived. No new replies allowed.