Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     double num;
  7.     char again;
  8.    
  9.     do
  10.     {
  11.         cout << "Enter an integer: ";
  12.         cin >> num;
  13.         //cout << endl;?
  14.         //(IT LOOKS LIKE IT DOESN'T NEED AN endl HERE)
  15.        
  16.         while (num != static_cast<int>(num))
  17.         {
  18.             cout << "ERROR. Enter an integer: ";
  19.             cin >> num;
  20.         }
  21.            
  22.         if (static_cast<int>(num) % 3 == 0)
  23.         {
  24.             if (static_cast<int>(num) % 5 == 0)
  25.             {
  26.                 cout << "FizzBuzz\n";
  27.             }
  28.             else
  29.             {
  30.                 cout << "Fizz\n";
  31.             }
  32.         }
  33.         else if (static_cast<int>(num) % 5 == 0)
  34.         {
  35.             cout << "Buzz\n";  
  36.         }
  37.         else
  38.         {
  39.             cout << "Blah\n";
  40.         }
  41.         //Does the user want to input another number?
  42.         cout << "Do you want to enter another number? (Y/N) ";
  43.         cin >> again;
  44.     } while (again == 'Y' || again == 'y');
  45.    
  46.     return 0;  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement