ceiling floor and round as const int - Need Help

I am very new to programming and was given a HW assignment in which I am to use ceil(), floor(), and round() functions for a real number (4.78). I understand how these functions work in that it rounds up or down but I do not under stand why the HW asks that we assign a const int value to to theses functions. The assignment is below. How does assigning const int value to the floor, ceiling and round help me solve this problem?

Define the following constants:
const int FLOOR_ROUND = 1;
const int CEILING_ROUND = 2;
const int ROUND = 3;

Write a program that asks the user to enter a Real number,then it asks the user to enter the method by which they want to round that number(floor,ceiling or to the nearest integer).

The program will then print the rounded result.Your program should interact with the user exactly as it shows in the following example:

Please enter a Real number:
4.78

Choose your rounding method:
1. Floor round
2. Ceiling round
3. Round to the nearest whole number

2
5

Any help on this would be so useful cause I do not know where to start given that we are using a const int that to me do not relate to the real number 4.78
Use if statements to compare the number entered to the const ints.
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 <cmath>
// partial program
int main()
{
    const int FLOOR_ROUND = 1;
    const int CEILING_ROUND = 2;
    const int ROUND = 3;

    std::cout << "enter real number: ";
    double n;
    std::cin >> n;

    std::cout << "Enter method (1 - Floor, 2 - Ceil, 3 - Round): ";
    int method;
    std::cin >> method;

    if (method == FLOOR_ROUND)
    {
        // do std::floor
    }
    else if (method == CEILING_ROUND)
    {
        // do std::ceil
     }
     else if (method == ROUND)
     {
        // do std::round
    }
}
it's for ease of use with constructs like switch statements, which are often peppered with constants.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
switch(choice)
{
    case FLOOR_ROUND:
        //logic
        break;

    case CEILING_ROUND:
        //logic
        break;

    case ROUND :
        //logic
        break;

    default:
        //erroneous choice logic
        break;
}
Topic archived. No new replies allowed.