Pls check the code. for example during betting if you write "One"
if the dice comes 1, you win. but when you write one it writes 2.28 1026 why.
I dont want case sensitive and it would be perfect if the first and second character I write for input, it must do.
#include <iostream> //
#include <stdlib.h> //
#include <ctype.h> //
#include <time.h> //
#include <string.h> //
using namespace std;
int Burcin(); // game function.
int main()
{
double total_money; // total money....
double betting_money; // betting money.
char Exit = 'Y'; // Yes or no for the game.....
cout<<"Welcome"<<endl<<endl;
cout<<"how much money you have in your pocket? usd ";
cin>>total_money; // enter total money that you have
cout<<endl<<endl; //
// Loops working until no .... in turkish H
while(toupper(Exit) != 'N')
{
cout<<"Betting!"<<endl<<endl;
cout <<"now you have: "<<total_money<<endl;
cout <<"how much you bet. ? $ ";
cin>>betting_money; // betting money
cout<<endl<<endl;
total_money = total_money - betting_money; // substract betting money from your pocket money
total_money = total_money + (betting_money * Burcin()); // Add winning bet;
// you dont have bucks....
if (total_money < 1)
{
cout<<endl<<endl<<"find money !"; // find money....
cout <<endl<<endl;
break;
}
//
cout<<endl<<endl<<"do you want to play again (Y veya N)? "; // do you want to play
cin>>Exit;
cout<<endl<<endl<<endl;
}
cout<<"thanks for playing with this program !"<<endl<<endl;
}
int Burcin()
{
char answer[15]=""; // answer
int Dice; // dice to be rolled
// Print the choices
cout<<"[ One Two Three Four Five Six] "; // onee two three four five six
// Prompt the user
cout<<"\n\n\nwhich one you choose.? "<<endl; // which one you prefer
cin>>answer; // Receive input
srand((unsigned)time( NULL ));
Dice = rand() % 6+1; // produce random for dice.
cout <<"winning number "<<Dice<<" !"<<endl; // output number is....
// control reseult......
if(strcmp(answer,"One") == 0)
{
if (Dice == 1)
{
cout<<"you win !"<<endl; // you win
return 6; // you win 6 times from your bet.
}
else
{
cout<<"you lose !"<<endl; // you lose
return 0;
}
}
if(strcmp(answer,"Two") == 0)
{
if (Dice == 2)
{
cout<<"you win!"<<endl;
return 6;
}
else
{
cout<<"you lose!"<<endl;
return 0;
}
}
if(strcmp(answer,"Three") == 0)
{
if (Dice== 3)
{
cout<<"You win!"<<endl;
return 6;
}
else
{
cout<<"You lose!"<<endl;
return 0;
}
}
if(strcmp(answer,"Four") == 0)
{
if (Dice == 4)
{
cout<<"You win!"<<endl;
return 6;
}
else
{
cout<<"you lose!"<<endl;
return 0;
}
}
if(strcmp(answer,"Five") == 0)
{
if (Dice == 5)
{
cout<<"you win!"<<endl;
return 6;
}
else
{
cout<<"you lose!"<<endl;
return 0;
}
}
if(strcmp(answer,"Six") == 0)
{
if (Dice == 6)
{
cout<<"You win!"<<endl;
return 6;
}
else
{
cout<<"You lose!"<<endl;
return 0;
}
}
}