All MicroEvals
t0-01-energy-percent-format
Create MicroEval
Header image for t0-01-energy-percent-format

t0-01-energy-percent-format

T0

Prompt

You are fixing a bug in a small C# file. Below is the full contents of `EnergyDisplay.cs`, followed by the bug report. Reply with ONLY the complete corrected contents of `EnergyDisplay.cs` in a single C# code block - no explanation before or after the code block. ## Current file: EnergyDisplay.cs ```csharp namespace EnergyDisplayKata; public static class EnergyDisplay { /// <summary>Formats energy as a whole-number percentage string, e.g. "25%".</summary> public static string FormatPercent(double energy, double maxEnergy) { var fraction = energy / maxEnergy; return (int)fraction + "%"; } } ``` ## Bug report `FormatPercent(energy, maxEnergy)` is supposed to return the energy level as a whole-number percentage string, e.g. `FormatPercent(50, 200)` should return `"25%"`. Instead it returns `"0%"` for any fraction below 100%, and `"1%"` when energy equals max. ## Your task Fix `FormatPercent` so it returns the correct whole-number percentage string. Do not change the method signature. Make the smallest change that fixes the bug. Reply with ONLY the corrected `EnergyDisplay.cs` file in one C# code block.