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);
        }
    }
}

'C#프로그래밍' 카테고리의 다른 글

2023-07-19 과제  (0) 2023.07.20
스타크래프트  (0) 2023.07.19
변환(캐스팅)  (0) 2023.07.19
디아블로 아이템 사전  (0) 2023.07.19
문자열 보간  (0) 2023.07.19