c语⾔case怎么输⼊字母,如何使⽤switchcase语句将字母转换
为数字
我正在制作⿊⾊插⼝游戏,并且需要使⽤switch case语句将A转换为11,将T,Q,J和K转换为10,但是我不确定如何执⾏代码。有⼈会帮助我解决这个问题吗?如何使⽤switch case语句将字母转换为数字
到⽬前为⽌,我有:
using System;java switch case string
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to Black Jack!\n");
Console.WriteLine("Pick two cards to add to your hand\n");
Console.WriteLine("Cards 2, 3, 4, 5, 6, 7, 8, 9 all are worth face value\n");
Console.WriteLine("Ace (A) is worth 11,Ten (T), Jack (J), Queen (Q), and King (K) are all worth 10 points\n");
Console.WriteLine("Whichever sum is higher, that player is declared the winner\n");
Console.WriteLine("What are player one's cards?");
Console.WriteLine("Enter card1 =?");
Console.WriteLine("Enter card2 =?");
double card1 = Double.Parse(Console.ReadLine());
double card2 = Double.Parse(Console.ReadLine());
Console.WriteLine("You entered: [" + card1, card2 + "]");
Console.WriteLine("What are player two's cards?");
Console.WriteLine("Enter card3 =?");
Console.WriteLine("Enter card4 =?");
double card3 = Double.Parse(Console.ReadLine());
double card4 = Double.Parse(Console.ReadLine());
Console.WriteLine("You entered: [" + card3, card4 + "]");
Console.ReadLine();
{
Console.WriteLine("Calculate player 1: [" + "card1 + card2" + "]");
Console.WriteLine("Calculate player 2: [" + "card3 + card4" + "]");
{
if (card1 + card2 > card3 + card4)
Console.WriteLine("Player One Wins!");
else if (card3 + card4 > card1 + card2)
Console.WriteLine("Player Two Wins!");
Console.ReadLine();
2010-02-17
Saisano
+0
鉴于你的代码的风格和使⽤系统命名空间,不应该被标记为C#不是Java? –
2010-02-17 01:12:23
+2
为什么这篇⽂章被标记为'java'?它看起来像是关于C#。 –
2010-02-17 01:12:31
+0
我并不认为有必要将你的整个代码粘贴到这样⼀个简单的问题上,但我想太多的东西⽐太少了。 –2010-02-17 01:14:08

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。