Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int ROUND_DOWN = 1;
  5. const int ROUND_UP = 2;
  6. const int ROUND = 3;
  7.  
  8. void main()
  9. {
  10.     double num;
  11.     int opt;
  12.  
  13.     cout << "Choose your round method:\n" << "1. Floor round\n" << "2. Ceiling round\n" << "3. Round to the nearest whole number\n";
  14.     cin >> opt;
  15.     if (opt>=1 && opt<=3)
  16.     {
  17.         cout << "Please enter the number you'd like to round with the method you chose: ";
  18.         cin >> num;
  19.  
  20.         if (opt = ROUND_DOWN)
  21.         {
  22.             cout <<"The floor round of "<< num <<" is: "<<(int)num;
  23.         }
  24.         if (opt = ROUND_UP)
  25.         {
  26.             cout << "The ceiling round of " << num << " is: " << (int)num+1;
  27.         }
  28.         if (opt = ROUND)
  29.         {
  30.             cout << "The nearest whole number to the number " << num << " is: " << (int)(num + 0.5);
  31.         }
  32.  
  33.     }
  34.  
  35.     else
  36.     {
  37.         cout << "Invalid choice,please restart the program and pick one of the 3 rounding options";
  38.     }
  39.  
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement