hi friends
This is my assignment
I have to send it today
I have many tests
please
You are my hope befor I drop this course (C++ course)
Please try to help me to solve it [/COLOR][/COLOR][/COLOR]

Write a C++ program that repeatedly display the following main menu :
The program menu offers the following options with their corresponding functions :
1- Is Prime Number? : IsPrime(num) , a bool function that receives an integer from the
program and decides if it is a prime number or not. For example :
Enter you choice : 1
Enter a positive number : 525
The number 525 is not a prime number.
2- List of prime numbers : List_Prime(x,y), a void function that lists all prime numbers between
x and y (x,y are included). For example :
enter your choice : 2
Enter two positive integers x,y (where x < y) : 12 69
Prime numbers between 12 and 69 are :
13 17 19 23 29 31 37 41 43 47 53 59 61 67
3- Is Palindromic Number? : Palindromic(num), a function that receives an integer from the
program and returns the reversal of the number to the program. According to the result the
program should decide if it is palindromic number or not. For example :
Enter your choice : 3
Enter a positive integer : 123
The number 123 is not a plaindromic number.
4- Emrip Numbers : Emrip(), a function that lists all emrip numbers between 2 and 1000 and
returns their count to the program. For example :
Enter your choice : 4
2 3 5 7 11 13 17 31 37 71 73 79 97 101 107 113 131 149 ….
There are 56 emrip numbers between 2 and 1000.
5- Palindromic Prime Numbers : Palind_Prime(), a void function that lists the first 100
palindromic prime numbers with 5 numbers in each line. For Example :
Enter your choice : 5
2 3 5 7 11
101 131 151 181 191
313 353 373 383 727
….
6- Mersenne Prime Numbers : Mersen_Prime(), a function that prints all mersenne prime numbers
(for p between 2 and 31) and returns their count to the program. For Example:
Enter your choice : 6
P 2^p – 1
2 3
3 7
5 31
….
There are 8 mersenne prime number for p ≤ 31.
7- Exit : Exit the main menu.

Edited 3 Years Ago by Reverend Jim: Fixed formatting

Aaahhh my eyes... Please don't use color tags in plain text.

Also: This is not a homework service. No one will write your homework for you if you show no effort at all. This is explained here

So what have you made so far? Please use [code=cplusplus] // code here [/code] tags when you post your code.

If you have nothing yet, it will become quite a challenge to finish on time, but I can't feel too sorry for you because you probably knew that your assignment was due today?

You could use the searchbox on the right to look for the palindrome and prime problem, because there have been a lot of threads about these problems

Niek

hi my friend ... this is what i did for u!!
Sallam 3ala miss Fayza!!!

# include <fstream>
# include <iostream>
# include <cmath>
using namespace std;
// prototype
bool IsPrime(int );
void List_Prime(int num2 , int num1 );
void Palindromic(int );
void Emrip();
void Palind_Prime();
void mersenne();
bool IsPrime2( long );
int main()
{
int ch,x, y, z=8, digit, mrs;
char loop='y';
while (loop=='y'||loop=='Y'){
// ********************** THE MAIN MENU ***************************** //

	cout<<"      ********************************************"<<endl
		<<"      **************   WELCOME TO   **************"<<endl
		<<"      ********   PRIME NUMBERS PROGRAM   *********"<<endl
		<<"      ********************************************"<<endl<<endl

		<<"*********************************************************"<<endl
		<<"1-  Is Prime Number ?"<<endl
		<<"2-  List of Prime numbers "<<endl
		<<"3-  Is Palindromic Number ?"<<endl
		<<"4-  Emrip Numbers"<<endl
		<<"5-  Palindromic Number "<<endl
		<<"6-  Mersenne Prime Number"<<endl
		<<"7-  Exit"<<endl
		<<"*********************************************************"<<endl
		<<endl
		<<"Enter your choice --> ";
	cin>>ch;



// switch function for the main menu
switch (ch)

{


// All the cases
case 1:
	{
		cout<<endl
			<<"Enter a positive integer number:";
        cin >> x;
		cout <<endl;
		IsPrime( x );
        cout<<endl;
		cout<<"Do U Want To Try Again (y/n)?";
		cin>>loop;
	cout<<"----------------------"
			<<endl<<endl;
	}
	break;
case 2:
	{
		cout<<endl
			<<"Enter two positive integers x,y (where x < y) :";
        cin >> x>>y;
		cout<<"Prime numbers between "<<x<<" and "<<y <<" are :"<<endl;
List_Prime(x,y);
cout<<endl;
		cout<<"Do U Want To Try Again (y/n)?";
		cin>>loop;
	cout<<"----------------------"
			<<endl<<endl;
	}
	break;
case 3:
	{
	cout<<endl
		<<"Enter a positive integer : ";
cin>>digit;
Palindromic(digit); 
cout<<endl;
		cout<<"Do U Want To Try Again (y/n)?";
		cin>>loop;
	cout<<"----------------------"
			<<endl<<endl;

	}
	break;
case 4:
	{
 Emrip();
	
 cout<<endl;
		cout<<"Do U Want To Try Again (y/n)?";
		cin>>loop;
			cout<<"----------------------"
			<<endl<<endl;
	}
	break;

case 5:
	{
	Palind_Prime();
cout<<"Please wait....."<<endl;
mersenne();
int p=2;
ifstream fin;
fin.open("mersenne.txt");
while (!fin.eof()){
fin>>mrs;
IsPrime2( mrs );


	}
cout<<"There are "<<z<<" mersenne prime number for p <= 31.";		
		cout<<endl;
		cout<<"Do U Want To Try Again (y/n)?";
		cin>>loop;
		cout<<"----------------------"
			<<endl<<endl;
	}
	break;
case 6:
	{
cout<<"Please wait.....!! wait wait dont worry! u will be happy...Wait 30 sec"<<endl;
mersenne();
int p=2;
ifstream fin;
fin.open("mersenne.txt");
cout<<"P"<<"\t"<<"2^p -1"<<endl;
while (!fin.eof()){
fin>>mrs;
IsPrime2( mrs );


	}
cout<<"There are "<<z<<" mersenne prime number for p <= 31.";
	cout<<endl;
		cout<<"Do U Want To Try Again (y/n)?";
		cin>>loop;
			cout<<"----------------------"
			<<endl<<endl;
	}
	break;
case 7:
	{
		return 0 ;
	}


}
}
	return 0;

}
// ****************************************************************** //
// ********************** THE FUNCTIONS ***************************** //
// ****************************************************************** //


/*** Prime Checking Function ***/

bool IsPrime(int x ){
	
for (int k=2; k<x;k++)
{
	if (x%k==0){
cout<<"The number ["<<x<<"] is NOT a prime integer number!!"<<endl;
break;
	}
else if (k==x-1)
cout<<"The number ["<<x<<"] is a prime integer number!!"<<endl;
}
if (x==1||x==2)
cout<<"The number ["<<x<<"] is a prime integer number!!"<<endl;
	

	return 0;
}




/*** Prime listing Function ***/

	void List_Prime(int num2 , int num1 ){

    for(int prime =num2;prime<num1;prime++){
    for( int num3=2; num3<= (prime/num3);num3++)
     if(!(prime%num3)) break;
     if(num3 >(prime/num3))
   cout << prime << " ";
    }
  cout <<endl;
	}



/*** Palindromic checking Function ***/
void Palindromic(int digit )
{
ofstream fout;
ifstream fin;
fout.open("temp_file.txt");
	int temp, fdigit;
	int temp2=digit;
//start loop to reverse the digit
	while(temp2/10!=0)
	{
		temp=temp2%10;
		temp2 =temp2/10;
		fout<<temp;
		if (temp2/10==0)
		fout<<temp2;
		
	}
fout.close();

fin.open("temp_file.txt");
fin>>fdigit;
if (fdigit==digit)
cout <<endl
     <<"The number ["<<digit<<"] is a plaindromic number."<<endl
	 <<endl;
else if (digit>=1&& digit<=9)
{
     cout<<"The number ["<<digit<<"] is a plaindromic number."<<endl
	 <<endl;
}
else
cout <<endl
     <<"The number ["<<digit<<"] is NOT a plaindromic number."<<endl
     <<endl;
fout.close();
}



/*** Emrip nymbers Function ***/
void Emrip()
{
ofstream fout, write;
fout.open("emrip.txt");
for(int prime =2;prime<1000;prime++){
    for( int num3=2; num3<= (prime/num3);num3++)
     if(!(prime%num3)) break;
     if(num3 >(prime/num3))
		 fout <<prime << " ";
    }
fout.close();

int fprime, temp, temp2,x,i=0;
ifstream fin,read;
write.open("emriprv.txt");
fin.open("emrip.txt");

while (!fin.eof())
{
fin>>fprime;
temp2=fprime;

while(temp2/10!=0)
	{
		
		temp=temp2%10;
		temp2 =temp2/10;
		write<<temp;
		if (temp2/10==0)
		write<<temp2<<" ";

		
	}

}
write.close();
fin.close();

read.open("emriprv.txt");

while (!read.eof())
{
read>>x;
	
for (int k=2; k<x;k++)
{
	if (x%k==0){
break;
	}
else if (k==x-1)
{
cout<<x<<"\t ";
i++;
}
}

}
cout<<endl<<endl<<"There are "<<i+4 <<" emrip numbers between 2 and 1000."<<endl;
}

//Palind function
//********************************
void Palind_Prime()
{
ofstream fout;
ifstream fin;
fout.open("mersenne.txt");
}


//Mersenne function
//********************************
void mersenne()
{

ofstream fout;
ifstream fin;
fout.open("mersenne.txt");	
long int res;

for (int p=2; p<=31; p++)
{
res = (pow(2,p)) -1;
fout<<" "<<res;

}
fout.close();
		
	
}



// Helper function to check if the number from a loop is APRIME or not
//********************************

bool IsPrime2(long  x ){




for (int k=2; k<x;k++)
{

	if (x%k==0){

break;
	}
else if (k==x-1)

cout << long(( log(( x)+1))/(log( 2)))<<"\t"<<x<<endl;

}




	return 0;




}
// copywrite Ahmed ...62090!
This question has already been answered. Start a new discussion instead.