Advertisement
4valeri

Phone Processes

Feb 6th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7.  
  8. class PhoneProcesses
  9. {
  10.     static void Main(string[] args)
  11.     {
  12.         int batteryLife = int.Parse(Console.ReadLine().Replace("%",""));
  13.         int programs = 0;
  14.  
  15.         while (true)
  16.         {
  17.             string appsPercent = Console.ReadLine();
  18.  
  19.             if (appsPercent.ToLower() == "end")
  20.             {
  21.                 break;
  22.             }
  23.  
  24.             else if (batteryLife > 15)
  25.             {
  26.                 string[] split = appsPercent.Split('_');
  27.                 int appsLife = int.Parse(split[1].Replace("%",""));
  28.                 batteryLife -= appsLife;
  29.             }
  30.  
  31.             else
  32.             {
  33.                 programs++;
  34.             }
  35.  
  36.            
  37.         }
  38.  
  39.         if (batteryLife <= 0)
  40.         {
  41.             Console.WriteLine("Phone Off");
  42.         }
  43.  
  44.         else if (batteryLife <= 15)
  45.         {
  46.             Console.WriteLine("Connect charger -> {0}%\nPrograms left -> {1}",
  47.                 batteryLife,
  48.                 programs);
  49.         }
  50.  
  51.         else
  52.         {
  53.             Console.WriteLine("Successful complete -> {0}%", batteryLife);
  54.         }
  55.        
  56.     }
  57.  
  58.  
  59.  
  60.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement