What does round to one decimal place of percision means?

I want to know what "Make sure the output of the program displays the number of slices in fixed point notation, rounded to one decimal place of precision." means in Problem #1

when it states round to one decimal place of precision, what does it mean?

For example, when I input 15 and it calculate the number of slices I should cut the pizza into 12.5
Does round to one decimal place of precision mean that it should round to 13 ? instead of 12.5? Or what I have is correct?


As well is the types of my variables correct?

I read a cplusplus book and I still cant answer it... im a bit confused.





Problem #1 ===================================================
Joe's Pizza Palace needs a program to calculate the number of slices a pizza of any size
can be divided into. The program should perform the following steps:

A) Ask the user for the diameter of the pizza in inches.
B) Calculate the number of slices that may be taken from a pizza of that size.
C) Display a message telling the number of slices.
To calculate the number
of slices that may be taken from the pizza, you must know
the
following facts:
• Each slice should have an area of 14.125 inches.
• To calculate the number of slices, simply divide the area of the pizza by 14.125.
• The area of the pizza is calculated with this formula:
Area = p*r^2

NOTE: 1t is the Greek letter pi. 3.14159 can be used as its value . The variable r is the
radius of the pizza. Divide the diameter by 2 to get the radius.

Make sure the output of the program displays the number of slices in fixed point
notation, rounded to one decimal place of precision. Use a named constant for pi.
=================================================================

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
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    
    double d_pizza,             // diameter of pizza in inches.
           r_pizza,             // radius of pizza in inches.
           num_slices,          // total number of slices for a pizza.
           area;                // the total area in inches of a pizza.
           
    const float PI = 3.14159;   


    cout << "What is the diamater of the pizza in inches? ";
    cin >> d_pizza;
    
    r_pizza = (d_pizza/2);
    area = pow(r_pizza,2.0) * PI; 
    num_slices = area / 14.125;
    cout << setprecision(1) << fixed;
    cout << "The number of slices that the pizza: " <<
         num_slices << endl;
    
    return 0;
}
Last edited on
Does round to one decimal place of precision mean that it should round to 13 ? instead of 12.5?

13 has zero digits after the decimal point.
12.5 has one digit after the decimal point - this is one decimal place of precision.

Or what I have is correct?
Yes
Topic archived. No new replies allowed.