Can somebody help me with this code. The program need to repeat until the user wants to quit.
#include<conio.h>
#include<iostream>
#include <cstdlib>
#include <stdlib.h>
using namespace std;
int opcio1();
int opcio2();
int opcio3();
int main()
{
int choice;
cout << "==========================================" << endl;
cout << " Menu" << endl;
cout << "==========================================" << endl;
cout << "1.Fortune Teller" << endl;
cout << "2.Stock Market" << endl;
cout << "==========================================" << endl;
cout<<"For fortune teller press 1, for stock market press 2"<<endl;
cin>>choice;
if (choice == 1) opcio1();
else if (choice == 2) opcio2();
else cout << "Use only number shown in the menu" << endl;
}
int opcio1()//Stock Market
{
char sentence[100];
cout<<"Ask what you should do in the market today!"<<endl;
cin.getline (sentence,100);
cin.ignore();
int theNumber;
theNumber = 1 + rand() % 3;
switch (theNumber)
{
case 1:
cout<<"You should definetly buy!"<<endl;
break;
case 2:
cout<<"Sell!Sell!Sell!"<<endl;
break;
case 3:
cout<<"Heck if I know. Go ask your brocker."<<endl;
break;
default:
break;
}
system("cls");
return opcio3();
}
int opcio2()//Fortune teller
{
char sentence[100];
cout<<"Do you feel lucky today!"<<endl;
cin.getline (sentence,100);
cin.ignore();
int theNumbers;
theNumbers = 1 + rand() % 4;
if (theNumbers == 1)
{
cout<<"No way!"<<endl;
}
else if (theNumbers == 2)
{
cout<<"Most Likely, yes!"<<endl;
}
else if (theNumbers ==3)
{
cout<<"Try again tomorrow!"<<endl;
}
else if (theNumbers == 4)
{
cout<<"Yes. I belive so!"<<endl;
}
system("cls");
return opcio3();
}
int opcio3()
{
int choice1;
cout<<"If you want to exit press 1, for starting over press 2"<<endl;
cin>>choice1;
if (choice1 == 1) exit(-1);
else if(choice1 == 2) main();
else cout << "Use only number shown in the menu" << endl;
}