I wrote a program to do different calculations.I wrote it so that everytime a user enters a choice,it does a different calculation.After the user finishes its supposed to give the user a choice to enter another choice or zero to finish.Im having trouble getting it to go to another option.I have a feeling my problem involves the brackets with my if statements. If anybody can help,id appreciate it.
Note:this is just the main of the program,the rest of it is just the various functions for the calculations.
int main()
{
//ofstream outf("f://output.txt",ios::out);
int choice;
cout<<"Enter a number between 1 and 5: ";
cin>>choice;
if (choice==1)
{
cout<<"This calculates GCD"<<endl;
cout << "A: ";
cin >> a;
cout << "N: ";
cin >> n;
cout << "GCD ("<<a<<","<<n<<")="<< gcd(a,n) << endl;
cout<<"Enter a number between 1 and 5 or 0 to end the program"<<endl;
cin>>choice;
}
elseif(choice==2)
{
cout<<"This calculates Extended euclid"<<endl;
cout << "A: ";
cin >> a;
cout << "N: ";
cin >> n;
extendedeuclid(a,n);
cout<<"Enter a number between 1 and 5 or 0 to end the program"<<endl;
cin>>choice;
}
elseif(choice==3)
{
cout<<"This calculates MODULAR-LINEAR-EQUATION-SOLVER"<<endl;
cout << "A: ";
cin >> a;
cout << "N: ";
cin >> n;
cout<<"b:"<<endl;
cin>>b;
cout<<"Number of solutions:"<<modularlinear(a,b,n)<<endl;
cout<<"Enter a number between 1 and 5 or 0 to end the program"<<endl;
cin>>choice;
}
elseif(choice==4)
{
cout<<"This calculates MODULAR-EXPONENTIATION"<<endl;
cout<<"m: "<<endl;
cin>>m;
cout<<"e: "<<endl;
cin>>e;
cout<<"n : "<<endl;
cin>>n;
cout<<"M^e (mod n) = "<<mod_pow(m,e,n)<<endl;
cout<<"Enter a number between 1 and 5 or 0 to end the program"<<endl;
cin>>choice;
}
elseif(choice==5)
{
cout<<"This finds the RSA Keys"<<endl;
cout<<"p:"<<endl;
cin>>p;
cout<<"q:"<<endl;
cin>>q;
cout<<"e:"<<endl;
cin>>e;
rsa(p,q,e);
cout<<"Enter a number between 1 and 5 or 0 to end the program"<<endl;
cin>>choice;
}
elseif (choice==0)
{
cout<<"Program Completed"<<endl;
}
system("pause");
return 0;
}