Last active
August 29, 2015 14:27
-
-
Save vdonchev/1c1ac03d0bce116cb75d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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