#include #include #include using namespace std; void PropertiesOf (const int n); bool IsPrime (const int n); int NextPrime(const int n); int PrevPrime(const int n); int main() { cout << "Number Personalities Program by Heritage High School (Team B)"; while (true) { int n = 0; cout << "\n\nPlease input an integer: "; cin >> n; PropertiesOf(n); } system("PAUSE"); return 0; } void PropertiesOf (const int n) { cout << "The number is "; // Positive or Negative if (n>0) cout << "positive"; else if (n<0) cout << "negative"; else cout << "zero"; // Even or Odd if (n!=0 && n%2==0) cout << ", even"; else if (n!=0 && n%2!=0) cout << ", odd"; // Prime if (IsPrime(n) && n>0) cout << ", prime" << ", " << NextPrime(n); else if (!IsPrime(n) && n>0) cout << ", " << PrevPrime(n); } bool IsPrime (const int n) { bool prime = false; int i=1; while (i<=n) { if (n<=0 || n%i==0 && i!=n && i!=1) return false; i++; } return true; } int NextPrime (const int n) { if (IsPrime(n)) { int i=n+1; while (!IsPrime(i)) { i++; } return i; } } int PrevPrime (const int n) { if (!IsPrime(n)) { int i=n-1; while (!IsPrime(i)) { i--; } return i; } }