(二) 任務(wù)二:實(shí)現(xiàn)循環(huán)執(zhí)行功能
- 需求說明
(1) . 系統(tǒng)詢問用戶是否繼續(xù)
(2) . 如果用戶選擇繼續(xù),則可以繼續(xù)選擇菜單,否則程序結(jié)束,退出系統(tǒng)
try
{
Console.WriteLine("[魔導(dǎo)師獎(jiǎng)勵(lì)系統(tǒng)>注冊(cè)]");
Console.Write("繼續(xù)選擇嗎?(y/n)");//提示用戶選擇
string b;
b = Console.ReadLine();
if (b == "y")
{
try
{
Console.WriteLine("歡迎進(jìn)入魔導(dǎo)師獎(jiǎng)勵(lì)系統(tǒng)");//提示
Console.Write(" 1.注冊(cè)\n 2.登錄\n 3.抽獎(jiǎng)\n");
Console.WriteLine("****************************");
Console.WriteLine("請(qǐng)選擇菜單:\t");
int a;
a = Convert.ToInt32(Console.ReadLine());
switch (a)
{
case 1:
Console.Write("注冊(cè)");
break;
case 2:
Console.Write("登錄");
break;
case 3:
Console.Write("抽獎(jiǎng)");
break;
default:
break;
}
}
catch
{
Console.WriteLine("你輸入的格式有誤");
}
}
else if (b == "n")
{
Console.WriteLine("系統(tǒng)退出,謝謝使用");
}
else
{
Console.WriteLine("輸入有誤");
}
}
catch
{
Console.WriteLine("你輸入的格式有誤");
}
Console.ReadKey();