#include<iostream>
void love();
void finance();
void school();
void decision();
//M. Jacobsen
//November 12th
//Lab 4 Exercise 4
usingnamespace std;
int main()
{
int favnum, retry;
cout << "Welcome! I am your personal psychic. I am capable of telling what the future holds for you." << endl;
cout << "Let's start with your lucky number... What might that be? ";
cin >> favnum;
cout << endl << endl;
srand(favnum);
decision();
cout << "Thank you for trusting my powers." << endl;
cout << "Care to know more? (y/n)";
cin >> retry;
if (retry == 'Y' || retry == 'y')
decision();
if (retry == 'N' || retry == 'n')
return 0;
}
void decision (void)
{
char decision;
cout << "Please type the first letter of the topic in which you would like predicted. Your options include: (L)ove, (F)inance, and (S)chool.";
cin >> decision;
cout << endl << endl;
cout << "Ahh.. I like that choice! Let me gaze into my Crystal Ball.." << endl;
if (decision == 'L' || decision == 'l')
love();
elseif (decision == 'F' || decision == 'f')
finance();
elseif (decision == 'S' || decision == 's')
school();
}
void love(void)
{
int x = rand()%5+1;
switch(x)
{
case 1:
cout << "Neverending happiness will quickly approach." << endl;
break;
case 2:
cout << "Don't search for love, let it find you." << endl;
break;
case 3:
cout << "Close friends may try to interfere with your love life. Overcome that obstacle to receive the key to happiness." << endl;
break;
case 4:
cout << "You will ask your crush out confidently.. and your confidence shall be rewarded." << endl;
break;
case 5:
cout << "You're going to live happily alone with the comfort of your pets." << endl;
break;
}
}
void finance(void)
{
int x = rand() % 5 + 1;
switch(x)
{
case 1:
cout << "Cha ching! You're gonna hit the lottery!" << endl;
break;
case 2:
cout << "You're going to live comfortably." << endl;
break;
case 3:
cout << "You have the potential to be a millionaire!" << endl;
break;
case 4:
cout << "Your lack of ingenuity will cause you to go broke." << endl;
break;
case 5:
cout << "Unfortunately, you are going to be unemployed for a while, but don't worry, your parents will take care of you." << endl;
break;
}
}
void school(void)
{
int x = rand() % 5 + 1;
switch(x)
{
case 1:
cout << "Your future holds an abundance of A's. Keep working hard." << endl;
break;
case 2:
cout << "Slacking off is going to ruin your GPA." << endl;
break;
case 3:
cout << "Hard work and dedication is what makes you unique. Your teachers are going to notice, as well as your future employers." << endl;
break;
case 4:
cout << "Just because you can get 80's without studying doesn't mean you shouldn't study. Always reach for the stars!" << endl;
break;
case 5:
cout << "Sure, C's get degrees, but they don't get high paying jobs.. Focus!" << endl;
break;
}
}
I like that you seeded srand() with the user's number choice.
You need to add something to handle incorrect user inputs, and implement near the end of main() so that they can try again. The 'retry' variable should not be declared as an int, but char.