Skip to content

Instantly share code, notes, and snippets.

@vdonchev
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdonchev/1c1ac03d0bce116cb75d to your computer and use it in GitHub Desktop.
Save vdonchev/1c1ac03d0bce116cb75d to your computer and use it in GitHub Desktop.
using System;
namespace PhoneProcesses
{
class Program
{
static void Main()
{
int batteryPercentage = int.Parse(Console.ReadLine().Replace("%", ""));
int remainingApps = 0;
while (true)
{
string application = Console.ReadLine();
if (application.ToLower() == "end") break;
if (batteryPercentage > 15)
{
string[] appDetails = application.Split('_');
int currApp = int.Parse(appDetails[1].Replace("%", ""));
batteryPercentage -= currApp;
}
else
{
remainingApps++;
}
}
if (batteryPercentage <= 0)
{
Console.WriteLine("Phone Off");
}
else if (batteryPercentage <= 15)
{
Console.WriteLine(
"Connect charger -> {0}%{2}Programs left -> {1}",
batteryPercentage,
remainingApps,
Environment.NewLine);
}
else
{
Console.WriteLine("Successful complete -> {0}%", batteryPercentage);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment