using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RoadBook.CsharpBasic.Chapter01.p0525
{
class Ex002
{
public void Run()
{
string[] weathers = new string[7];
weathers[0] = "suuny";
weathers[1] = "suuny";
weathers[2] = "rainy";
weathers[3] = "cloudy";
weathers[4] = "rainy";
weathers[5] = "snow";
weathers[6] = "suuny";
int dayCnt = weathers.Length;
int sunnyCnt = 0;
int cloudyCnt = 0;
int rainyCnt = 0;
int snowCnt = 0;
for(int idx=0; idx<dayCnt; idx++)
{
string weather = weathers[idx];
if(weather == "sunny")
{
sunnyCnt++;
}
else if (weather == "cloudy")
{
cloudyCnt++;
}
else if (weather == "rainy")
{
rainyCnt++;
}
else if (weather == "snow")
{
snowCnt++;
}
}
Console.WriteLine("맑음 : {0} / 흐림 : {1} / 비 : {2} / 눈 : {3}", sunnyCnt, cloudyCnt, rainyCnt, snowCnt);
}
}
}
'IT > C#' 카테고리의 다른 글
C# (팩토리얼 재귀함수) (0) | 2021.05.13 |
---|---|
C# (객체지향_자동차 클래스 설계) (0) | 2021.05.06 |
C# (은행 ATM 기기 프로그램) (0) | 2021.05.06 |
C# (사용자가 랜덤 숫자를 맞추는 프로그램) (0) | 2021.05.06 |
C# (팩토리얼 구하기) (0) | 2021.05.06 |