C#프로그래밍
영웅 피
다모아
2023. 7. 19. 17:20
using System;
using System.ComponentModel;
namespace HelloWorld
{
internal class Program
{
static void Main(string[] args)
{
int monsterDamage = 4;
int maxHeroHp = 15;
int heroHp = maxHeroHp;
Console.WriteLine("몬스터에게 공격을 받았습니다.");
heroHp = heroHp - monsterDamage; // 11
//영웅의 남은 체력 : 11 (0.73%) //11
float hpPercentage = ((float)heroHp / maxHeroHp) * 100;
Console.WriteLine("영웅의 남은 체력: {0}, ({1}%)", heroHp , (int)hpPercentage);
}
}
}