AFter asking for name, it doesn't ask for other things, just gets to the end where it says "game has been developed by.." Kindly guide me what i am doing wrong. i am a beginner, trying to learn. Thank you!
Here is my code:
#include<iostream>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
using namespace std;
void draw_line(int n,char ch);
void rules();
int main()
{
int balanceamount,amount,number,dice, name;
char ch;
system("cls");
draw_line(60,'=');
cout<<"\n\n\n\n\t\tWelcome to My Casino\n\n\n\n";
draw_line(60,'=');
cout<<"\n\n\n Please Enter Your Name: ";
cin>>name;
cout<<"\n\n\Please deposit the amount in your account: ";
cin>>balanceamount;
do
{
system("cls");
rules();
cout<<name<<"\n\nYour current balance is Rs."<<balanceamount;
do
{
cout<<"\n\n Kindly enter money you want to to bet ";
cin>>amount;
if(amount>balanceamount)
cout<<"Your betting amount is more than your current balance\n\nPlease re enter the amount: ";
else
break;
}while(1);
do
{
cout<<"Please enter your lucky number to bet between 1 to 10: ";
cin>>number;
if(number<=0||number>10)
cout<<"You number is not between 1 and 10. \n\n Please Re enter the number: ";
else
break;
}while(1);
srand ( time(NULL) );
dice= rand() % 10 + 1;
if(dice==number)
{
cout<<"\n\nCongrats! You have won Rs.: "<<amount*10;
balanceamount=balanceamount+amount*10;
}
else
{
cout<<"Tough luck! You lose Rs.: "<<amount;
balanceamount=balanceamount-amount;
}cout<<"\n\nThe winning number is: "<<dice;
cout<<"\n\n\t"<<name<<" You have Rs.: "<<balanceamount<<endl;
cout<<"\n\n-->Do you want to play more?\n\n (y/n) ";
cin>>ch;
}while(ch=='Y'|| ch=='y');
system("cls");
draw_line(70,'+');
cout<<"\n\n\Thank you for coming to my casino. Hope you had fun! Your Balance amount is: "<<balanceamount<<"\n\n";
draw_line(70,'+');
cout<<"\n\nGame developed by Sana Farooq\n";
draw_line(70,'+');
getch();
}
void draw_line(int n,char ch)
{
for(int i=0;i<n;i++)
cout<<ch;
}
void rules()
{
system("cls");
cout<<"\n\n";
draw_line(60,'-');
cout<<"\n\t\tRULES OF THE GAME\n";
draw_line(60,'-');
cout<<"\n1. Choose any number between 1 to 10\n2. If you win you will get 10 times of money you bet\n3. If you bet on wrong number you will lose your betting amount\n\n";
draw_line(60,'-');
cout<<endl;
}