My own version of the Magic 8-Ball activity in the C++ Learning Course. I added my own creative writing to it :)

It’s nothing special necessarily, I just had a ton of fun coming up with the answers and thought someone might share the same feelings!

#include
#include

int main() {

// Your future is here
std::cout << “MAGIC 8-BALL: \n”;

//sets the “seed” of the random number generator
srand(time(NULL));

int answer = std::rand() % 10;

std::cout << answer;

if (answer == 0) {

std::cout << " It is certain.\n";

}
else if(answer == 1) {

std::cout << " Very doubtful.\n";

}
else if (answer == 2) {

std::cout << " The stars do not align.\n";

}
else if (answer == 3) {

std::cout << " Perhaps the stars are willing to listen to reason.\n";

}
else if (answer == 4) {

std::cout << " A preposterous thing to even consider.\n";

}
else if (answer == 5) {

std::cout << " The stars shine their effervescent glow; it is a yes.\n";

}
else if (answer == 6) {

std::cout << " The stars have all disappeared from the sky. It doesn't look promising.\n";

}
else if (answer == 7) {

std::cout << " Only if you give me a kiss ;).\n";

}
else if (answer == 8) {

std::cout << " The stars once said to me: only when the sky blackens and we are nowhere to be seen, only then will your dreams come to fruition.\n";

}
else if (answer == 9) {

std::cout << " Absolutely!\n";

}
else if (answer == 10) {

std::cout << "Pffffffffftttttt......\n";

}
}

1 Like