using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Project4
{
class Class1
{
static int highscore = 300;
static string highscorePlayer = "Jan";
static void Main(string[] args)
{
CheckHighScore(250, "Joe");
CheckHighScore(315, "Mic");
CheckHighScore(350, "Sha");
Console.Read();
}
public static void CheckHighScore(int score, string playerName)
{
if (score > highscore)
{
highscore = score;
highscorePlayer = playerName;
Console.WriteLine("New highscore is " + score);
Console.WriteLine("It is now held by " + playerName);
}
else
{
Console.WriteLine("The old highscore could not be broken. It is still");
Console.WriteLine(highscore + "and held by" + highscorePlayer);
}
}
}
}
실행

'c# ☃️' 카테고리의 다른 글
[C#] do while 루프 반복문 사용법 (0) | 2024.05.03 |
---|---|
[C#] 삼항 연산자 - ?/:/if (3) | 2024.04.18 |
[C#] 스위치 기본 사용 - switch (0) | 2024.04.09 |
[C#] IF사용 - 간단 회원 확인 예제 (0) | 2024.04.08 |
[C#] 중첩 IF문 (0) | 2024.04.08 |