Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int ROUND_DOWN = 1;
- const int ROUND_UP = 2;
- const int ROUND = 3;
- void main()
- {
- double num;
- int opt;
- cout << "Choose your round method:\n" << "1. Floor round\n" << "2. Ceiling round\n" << "3. Round to the nearest whole number\n";
- cin >> opt;
- if (opt>=1 && opt<=3)
- {
- cout << "Please enter the number you'd like to round with the method you chose: ";
- cin >> num;
- if (opt = ROUND_DOWN)
- {
- cout <<"The floor round of "<< num <<" is: "<<(int)num;
- }
- if (opt = ROUND_UP)
- {
- cout << "The ceiling round of " << num << " is: " << (int)num+1;
- }
- if (opt = ROUND)
- {
- cout << "The nearest whole number to the number " << num << " is: " << (int)(num + 0.5);
- }
- }
- else
- {
- cout << "Invalid choice,please restart the program and pick one of the 3 rounding options";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement