Magic 8 Ball Dev C++

Berikut adalah kode program yang dapat memberikan keluaranMagic 8 Ball, kode bisa digunakan pada aplikasi DevC++ ataupun aplikasi program bahasa C lainnya.Bagi anda yang belum mempunyai Dev C++, bisa di download di Download Dev C++ , lalu silakan di install.

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;

int main(int argc, char *argv[])
{
srand(time(0));

string question;

getline(cin,question);
char lagi;
do
{
double ip;

cout << "Your question: " << question << endl << endl;

cout << "Magic 8-Ball : ";

switch(rand() % 20)
{
case 0: cout << "It is certain."; break;
case 1: cout << "It is decidedly so."; break;
case 2: cout << "Without a doubt."; break;
case 3: cout << "Yes definitely."; break;
case 4: cout << "You may rely on it."; break;
case 5: cout << "As I see it, yes."; break;
case 6: cout << "Most likely."; break;
case 7: cout << "Outlook good."; break;
case 8: cout << "Yes."; break;
case 9: cout << "Signs point to yes."; break;
case 10: cout << "Reply hazy try again."; break;
case 11: cout << "Ask again later."; break;
case 12: cout << "Better not tell you now."; break;
case 13: cout << "Cannot predict now."; break;
case 14: cout << "Concentrate and ask again."; break;
case 15: cout << "Don't count on it."; break;
case 16: cout << "My reply is no."; break;
case 17: cout << "My sources say no."; break;
case 18: cout << "Outlook not so good."; break;
case 19: cout << "Very doubtful."; break;
}
cout<<"\n\nReply [Y/T] : ";cin>>lagi;
}
while(lagi == 'y' || lagi == 'Y');
cout<<"\n";
cout <<"|==========================|\n";
cout <<"| TEKAN ENTER UNTUK KeLUAR!|\n";
cout <<"| creative:Faisal Haibib   |\n";
cout <<"===========================|\n";
return 0;
}

Dengan Hasil running :

 

 

 

Rich Snippets
Published
Ratings
51star1star1star1star1star

Kata Bijak? Google banyak!

You may also like...

Leave a Reply