public static void Main()
Console.WriteLine("Welcome to Game 21");
Console.WriteLine("Betting? If you win, you will get double. If you lose, you will be deducted; if it's a draw, there will be no change.");
Console.WriteLine("Enter your amount if you want to bet, enter 0 if you don't want to bet.($)");
double bet=Convert.ToDouble(Console.ReadLine());
Random rG = new Random();
Console.WriteLine("How many cards do you want to draw (2-4)?");
int nCards = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(new string('=',50));
Console.WriteLine("Your First Card: " +pC1+ "\nYour Second Card: " +pC2+"\nYour Score: "+pScore);
Console.WriteLine("Your First Card: " +pC1+ "\nYour Second Card: " +pC2+"\nYour Third Card: "+pC3+"\nYour Score: "+pScore);
pScore = pC1+pC2+pC3+pC4;
Console.WriteLine("Your First Card: " +pC1+ "\nYour Second Card: " +pC2+"\nYour Third Card: "+pC3+"\nYour Forth Card: "+pC4+"\nYour Score: "+pScore);
Console.WriteLine(new string('-',50));
Console.WriteLine("Computer's First Card: " +cC1+ "\nComputer's Second Card: " +cC2+"\nComputer's Score: "+cScore);
Console.WriteLine("Computer's First Card: " +cC1+ "\nComputer's Second Card: " +cC2+"\nComputer's Third Card: "+cC3+"\nComputer's Score: "+cScore);
cScore = cC1+cC2+cC3+cC4;
Console.WriteLine("Computer's First Card: " +cC1+ "\nComputer's Second Card: " +cC2+"\nComputer's Third Card: "+cC3+"\nComputer's Forth Card:"+cC4+"\nComputer's Score: "+cScore);
Console.WriteLine(new string('-',50));
if (pScore > 21 && cScore > 21)
{Console.WriteLine("You and the computer are over 21! It's a draw!");
{Console.WriteLine("You're over 21! The computer wins!");
{Console.WriteLine("The computer is over 21! You win!");
else if (cScore > pScore)
{Console.WriteLine("The computer wins!");
else if (pScore > cScore)
{Console.WriteLine("You win!");
{Console.WriteLine("Your numbers are the same!It's a draw!");
Console.WriteLine ("{0,-15}{1,8:C2}","Your balance:",balance);
Console.WriteLine(new string('=',50));
Console.WriteLine("Do you want to play again? (y=”yes”/ n=”no”)");
string again= Console.ReadLine();
Console.WriteLine("Let’s battle again!");
Console.WriteLine("Thanks for playing! Goodbye!");
Console.WriteLine("Invalid input. Please enter 'y' for yes or 'n' for no.");