题目
奖客富翁系统
代码
try
{
string shifou;
string name;
int password;
do
{
Console.WriteLine("*****欢迎进入奖课富翁系统*****");
Console.WriteLine(@"
1.注册
2.登录
3.抽奖");
Console.WriteLine("******************************");
Console.Write("请选择菜单:");
int daan = Convert.ToInt32(Console.ReadLine());
if (daan == 1)
{
Console.WriteLine("[奖课富翁系统>注册]");
Console.WriteLine("请输入个人注册信息:");
Console.Write("用户名:");
name = Console.ReadLine();
Console.Write("密码:");
password = Convert.ToInt32(Console.ReadLine());
Random random = new Random(); //随机生成会员卡号
int n = random.Next(1000, 9999);
Console.WriteLine("注册成功,请记好你的会员卡号");
Console.WriteLine("用户名\t密码\t会员卡号");
Console.WriteLine("{0}\t{1}\t{2}", name, password, n);
}
else if (daan == 2)
{
name = "admin";
password = 123456;
Console.WriteLine("[奖课富翁系统>登录]");
int a = 0;//储存用户名或者密码输错的次数
for (int i = 0; i < 3; i++)
{
Console.Write("请输入用户名:");
string name1 = Console.ReadLine();
Console.Write("请输入密码:");
int password1 = Convert.ToInt32(Console.ReadLine());
if (name1 == name && password1 == password)
{
Console.WriteLine("欢迎您:admin");
break;
}
else
{
Console.WriteLine("用户名或密码输入错误,请重新输入");
a++;
}
if (a == 3)
{
Console.WriteLine("你已经输错了三次,不能在输入");
}
}
}
else if (daan == 3)
{
Console.WriteLine("[奖课富翁系统>抽奖]");
Console.Write("请输入你的会员卡号:");
int vipnum = Convert.ToInt32(Console.ReadLine());
int[] xysz = new int[5];//xysz为幸运数字
Console.Write("本日的幸运数字为:");
for (int i = 0; i < 5; i++)
{
Random random = new Random();
int n = random.Next(1000, 9999);
xysz[i] = n;
Console.WriteLine(xysz[i] + "\t");
if (xysz[i] == vipnum)
{
Console.WriteLine("恭喜你,你是本日的幸运会员");
break;
}
if (i == 4)
{
Console.WriteLine("抱歉!你不是本日的幸运会员!");
}
}
}
else
{
Console.WriteLine("你输入的格式有误");
}
Console.Write("继续吗?(y/n):");
shifou = Console.ReadLine();
if (shifou == "n")
{
Console.WriteLine("系统退出,谢谢使用");
}
} while (shifou != "n");
}
catch
{
Console.WriteLine("你输入的格式有误");
}
Console.ReadKey();