string user; string newuser; string password;
string newpassword; int card;
int min = 1000; int max = 9999;
Random rd = new Random();
rd.Next(min, max);
try
{
Console.WriteLine("******欢迎进入奖客富翁系统******");
Console.WriteLine("\t\t1.注册");
Console.WriteLine("\t\t2.登录");
Console.WriteLine("\t\t3.抽奖");
Console.WriteLine("********************************");
Console.Write("请选择菜单:");
string a = Console.ReadLine();
switch (a)
{
case "1":
Console.WriteLine("奖客富翁系统>注册");
Console.Write("继续吗?(y/n):");
string b = Console.ReadLine();
if (b == "y")
{
Console.WriteLine("请填写个人注册信息:");
Console.Write("用户名:");
user = Console.ReadLine();
Console.Write("密码:");
password = Console.ReadLine();
Console.WriteLine("注册成功,请记好您的会员卡号");
Console.WriteLine("用户名\t\t\t密码\t\t\t会员卡号");
Console.WriteLine("{0}\t\t\t{1}\t\t\t{2}",user,password,rd.Next(min, max));
}
else if (b == "n")
{
Console.WriteLine("程序退出,谢谢使用!");
}
else
{
Console.WriteLine("您的输入有误");
}
break;
case "2":
Console.WriteLine("奖客富翁系统>登录");
int i = 3;
while (i>0)
{
Console.Write("请输入用户名:");
user = "admin";
newuser = Console.ReadLine();
Console.Write("请输入用户密码:");
password = "123456";
newpassword =Console.ReadLine();
if (newuser=="admin" && newpassword=="123456")
{
Console.WriteLine("{0},欢迎您的登录!",user);
break;
}
else
{
if (i>0)
{
Console.WriteLine("你还有{0}次机会",i-1);
i--;
continue;
}
else
{
Console.WriteLine("你没有机会了,退出程序!");
break;
}
}
}
break;
case "3":
Console.WriteLine("奖客富翁系统>抽奖");
Console.Write("请输入您的卡号:");
card = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("本日的随机数是:");
for (int d = 0; d < 5; d++)
{
Console.WriteLine("{0}", rd.Next(min, max));
}
if (card== rd.Next(min, max))
{
Console.WriteLine("");
}
else
{
Console.WriteLine("很抱歉,您不是本日会员!");
}
break;
default:
Console.WriteLine("您的输入有误!");
break;
}
}
catch
{
Console.WriteLine("您输入的格式有误,请重新输入!");
}
Console.ReadKey();
网友评论