Advertisement
plamen27

Fixed Phone Processes

Jul 21st, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. using System;
  2.  
  3. public class Program
  4. {
  5. public static void Main()
  6. {
  7.  
  8. int percent = int.Parse(Console.ReadLine().Replace("%", ""));
  9. string command = Console.ReadLine().ToLower();
  10.  
  11. int appsLeft = 0;
  12.  
  13. while (command != "end")
  14. {
  15. // string[] input = command.Split(new Char[] { '_', '%' });
  16. if (percent > 15)
  17. {
  18. //int batteryConsumption = int.Parse(input[1]);
  19. int batteryConsumption = int.Parse(command.Substring(command.Length - 3, 2));
  20. percent -= batteryConsumption;
  21. }
  22. else if (percent <= 15 && percent > 0)
  23. {
  24. appsLeft++;
  25. }
  26.  
  27. command = Console.ReadLine().ToLower();
  28. }
  29.  
  30. if (percent <= 0)
  31. {
  32. Console.WriteLine("Phone Off");
  33. }
  34. else if (percent <= 15)
  35. {
  36. Console.WriteLine("Connect charger -> {0}%", percent);
  37. Console.WriteLine("Programs left -> {0}", appsLeft);
  38. }
  39. else
  40. {
  41. Console.WriteLine("Successful complete -> {0}%", percent);
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement