Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class PhoneProcesses
- {
- static void Main(string[] args)
- {
- int batteryLife = int.Parse(Console.ReadLine().Replace("%",""));
- int programs = 0;
- while (true)
- {
- string appsPercent = Console.ReadLine();
- if (appsPercent.ToLower() == "end")
- {
- break;
- }
- else if (batteryLife > 15)
- {
- string[] split = appsPercent.Split('_');
- int appsLife = int.Parse(split[1].Replace("%",""));
- batteryLife -= appsLife;
- }
- else
- {
- programs++;
- }
- }
- if (batteryLife <= 0)
- {
- Console.WriteLine("Phone Off");
- }
- else if (batteryLife <= 15)
- {
- Console.WriteLine("Connect charger -> {0}%\nPrograms left -> {1}",
- batteryLife,
- programs);
- }
- else
- {
- Console.WriteLine("Successful complete -> {0}%", batteryLife);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement