Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Write a program, which displays information about a video game character. You will receive their name, current health, maximum health, current energy and maximum energy on separate lines. The current values will always be valid (equal or lower than their respective max values). Print them in the format as per the examples.
- using System;
- namespace _05._Character_Stats
- {
- class CharacterStats
- {
- static void Main(string[] args)
- {
- string name = Console.ReadLine();
- int currentHealth = int.Parse(Console.ReadLine());
- int maximumHealth = int.Parse(Console.ReadLine());
- int currentEnergy = int.Parse(Console.ReadLine());
- int maximumEnergy = int.Parse(Console.ReadLine());
- string health = "|" + new string('|', currentHealth) + new string('.', maximumHealth - currentHealth) + "|";
- string energy = "|" + new string('|', currentEnergy) + new string('.', maximumEnergy - currentEnergy) + "|";
- Console.WriteLine("Name: {0}", name);
- Console.WriteLine("Health: {0}",health);
- Console.WriteLine($"Energy: {energy}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment