I just finished the Magic 8-Ball project in C++. My suggestion for this project is to make it ask a question to the user along with using a switch case statement.
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
//The first line should be the same so output phrase MAGIC 8-BALL:.
cout << "MAGIC 8-BALL\n";
//We need to get a different random number for each execution.
//This sets the “seed” of the random number generator.
srand (time(NULL));
//So, create an int variable and set it equal to a random number:
//We want a random number from 0-9.
int random = rand() % 20;
//Ask a question!
string question;
cout << "What is your question?\n";
cin >> question;
//Write a statement if answer is 0, your program outputs "It is certain."
switch(random) {
case 0: cout << "It is certain.\n"; break;
case 1: cout << "It is decidedly so.\n"; break;
case 2: cout << "Without a doubt.\n"; break;
case 3: cout << "Yes - definitely.\n"; break;
case 4: cout << "You may rely on it.\n"; break;
case 5: cout << "As I see it, yes.\n"; break;
case 6: cout << "Most likely.\n"; break;
case 7: cout << "Outlook good.\n"; break;
case 8: cout << "Yes.\n"; break;
case 9: cout << "Signs point to yes.\n"; break;
case 10: cout << "Reply hazy, try again.\n"; break;
case 11: cout << "Ask again later.\n"; break;
case 12: cout << "Better not tell you now.\n"; break;
case 13: cout << "Cannot predict now.\n"; break;
case 14: cout << "Concentrate and ask again.\n"; break;
case 15: cout << "Don't count on it.\n"; break;
case 16: cout << "My reply is no.\n"; break;
case 17: cout << "My sources say no.\n"; break;
case 18: cout << "Outlook not so good.\n"; break;
case 19: cout << "Very doubtful.\n"; break;
default: cout << "UNCAUGHT EXCEPTION! WTF did you do to get here?\n"; break;
}
//Exit Program
return 0;
}