#Failed Compile

26 messages · Page 1 of 1 (latest)

tall cosmos
#
#include <iostream>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;

int main()
{

   const double PI = M_PI;
   const double SLICE_SIZE = 14.125;
   // and the "slices per guest" defined constant
   const int SLICES_PER_GUEST = 2;
    
    // 1. Input, the number of party guests and the size pizza to buy
    cout << "Enter the number of guests expected (eg, 8): ";
    int guests;
    cin >> guests;
    
    cout << "Enter the pizza size to buy (eg, 14): ";
    double diameter;
    cin >> diameter;

    // 2. Calculate the estimate of "pizzas to buy for a party"
    //
    //--- Pseudocode to calculate the Total Area of pizza needed for party ----
    // a. let's first calculate the total area of pizza needed for the party guests.
    //
   // First declare a floating-point variable to hold the total_area
   // Then assign to this total_area variable, the calculated value below:
    float TOTAL_AREA = (guests)*(SLICES_PER_GUEST)*(SLICE_SIZE);
    //
    // b. calculate the pizza_area of a circular pizza of the given diameter
    double PIZZA_AREA = M_PI * diameter / 2;
   // c. next, calculate the floating-point ratio: total_area/pizza_area
    cout << TOTAL_AREA/PIZZA_AREA;
   
    //
    // d. finally, find the ceil() of the above ratio. This will be the
    // recommended whole number of pizzas to buy for the party (an integer).
    cout << "ceil(1.7) = " << ceil(1.7) << endl;
    cout << "ceil(1.2) = " << ceil(1.2) << endl;

   return 0;
}

PIZZA_AREA not declared but its in there?

idle frigateBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

torpid frigate
#

i see pizza_area declared

#

i dont see PIZZA_AREA declaration

#

also u got a statement without semicolon

tall cosmos
#

I redid some code, but its still telling me PIZZA_AREA not declared

torpid frigate
#

ye, its not

tall cosmos
#

So under B where I calc the pizza area it should be float instead of double?

#

Oh okay I was missing my ;'s

#

I'm dumb ty ty

torpid frigate
#

did u edit, PIZZA_AREA wasnt declared on ur original message

#

and yea

#

u also missed a ;

#

name identifiers are case sensitive in c++

tall cosmos
#

Updated message

torpid frigate
#

so PIZZA and pizza refer different variables

tall cosmos
#

To show code I have in right now

torpid frigate
#

oki

tall cosmos
#

the ceil() function

#

does it stay blank

#

or do I have to have a number in there

#

so the outcome is a whole number

torpid frigate
idle frigateBOT
#

@tall cosmos Has your question been resolved? If so, run !solved :)

tall cosmos
#

Ty @torpid frigate

#

!solved