Question: Number.cpp: #include #include #include #include Number.h using namespace std; Number::Number(int n) { number=n; } bool Number::isPrime(void) { int n=number; for(int i=2;i
Number.cpp:
#include
#include
#include
Number::Number(int n) { number=n;
}
bool Number::isPrime(void)
{
int n=number; for(int i=2;i<=pow(n,0.5);i++)
{ if(n%i==0)
{
return false;
}
}
return true;
}
bool Number::isDivisibleBy(int n)
{ if(number%n==0)
return true;
return false;
}
Number.h
using namespace std; #ifndef NUMBER_H #define NUMBER_H class Number
{ public:
Number(int); bool isPrime(void); bool isDivisibleBy(int);
private:
int number;
}; #include "Number.cpp" #endif
Write a program that prompts the user to enter a number larger or equal to 2. The program should use the Number class you developed (Provided above) to determine the prime numbers between 2 and the number entered, and display them in the console window.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
