using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study01
{
class Program
{
static void Main(string[] args)
{
// int hp = 10;
// int att = 10;
// bool isDie = hp - att <= 0;
// if (isDie)
// {
// Console.WriteLine("사망");
// }
// else Console.WriteLine("생존");
int level = 1;
float exp = 98.56f;
float getExp = 45.23f;
Console.WriteLine("{0} 경험치를 획득하였습니다.", getExp);
exp = exp + getExp;
if(exp >= 100)
{
level++;
Console.WriteLine("레벨이 {0}에서 {1}가 되었습니다.", level - 1, level);
exp = exp - 100f;
Console.WriteLine("현재 경험치 : {0}", exp);
}
}
}
}
if문 사용 연습
2023. 1. 2. 12:37