Thank you for your help.
Here I made some improvements, but still I have small error:
error C2146: syntax error : missing ';' before identifier 'cout'
Here is the new version
Code:
#include<conio.h>
#include<iostream>
using namespace std;
int opcio1();
int opcio2();
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;
system ("PAUSE");
return 0;
}
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 ("PAUSE");
return 0;
}
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;
// = is assign, == is compare, you can just as well use a switch.
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 ("PAUSE");
return 0;
}
And I have one more question, after the program is done, how can I make a menu which can ask the user
Do you like to exit OR
Do you like to go back in the beginning?
Thank You