作業(yè)要求
為了維護(hù)用戶信息,需要將其信息錄入系統(tǒng)混弥,具體要求如下:
(1) .循環(huán)錄入用戶的信息趴乡,包括用戶編號(hào)、年齡剑逃、積分浙宜;(2) .判斷年齡是否合法官辽,要求用戶必須滿10周歲以上蛹磺。若年齡合法,則顯示錄入信息同仆,否則顯示錄入失敗萤捆。
代碼
...
Console.WriteLine("請(qǐng)輸入用戶數(shù)量");
int count = Convert.ToInt32(Console.ReadLine());
int custNo = 0;
int age;
int points = 0;
for (int i = 1; i <= count; i++)
{
Console.WriteLine("請(qǐng)輸入第{0}位的用戶信息", i);
Console.WriteLine("請(qǐng)輸入用戶編號(hào)(<4位整數(shù):)");
custNo = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("請(qǐng)輸入用戶年齡");
age = Convert.ToInt32(Console.ReadLine());
if (age < 10 || age > 100)
{
Console.WriteLine("很抱歉,您的年齡不適宜玩游戲");
Console.WriteLine("錄入信息失敗");
continue;
}
Console.WriteLine("請(qǐng)輸入用戶積分:");
points = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("您錄入的用戶信息是:");
Console.WriteLine("用戶編號(hào):" + custNo + "\t年齡:" + age + "\t積分:" + points + "\n");
}
Console.ReadKey();
...