- 輸入整數(1~12)表示月份,自動判斷季節。
##ReadMore##
檔案 → 新增專案 → 主控台應用程式 → 撰寫 Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Lesson_A._5
{
class Program
{
static void Main(string[] args)
{
Boolean flag = false;
while (true)
{
Console.WriteLine("===== 請輸入現在月份(1~12 or exit):");
string month = Console.ReadLine();
switch (month)
{
case "3":
case "4":
case "5":
Console.WriteLine("現在是春天…");
break;
case "6":
case "7":
case "8":
Console.WriteLine("現在是夏天…");
break;
case "9":
case "10":
case "11":
Console.WriteLine("現在是秋天…");
break;
case "12":
case "1":
case "2":
Console.WriteLine("現在是冬天…");
break;
case "exit":
flag = true;
break;
default:
Console.WriteLine("輸入錯誤…");
break;
}
if (flag == true)
break;
}
}
}
}
沒有留言:
張貼留言