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;
- namespace Divicing
- {
- class Program
- {
- static void Main(string[] args)
- {
- string inPower = Console.ReadLine();
- inPower = inPower.Replace("%", "");
- int power = int.Parse(inPower);
- int battCheck = 0;
- int battCheckOff = 0;
- int counter = 0;
- if (power <= 15 && power > 0)
- {
- battCheck = 1;
- }
- else if (power <= 0)
- {
- battCheckOff = 1;
- }
- string prog = Console.ReadLine();
- while (!prog.ToLower().Equals("end"))
- {
- if (battCheck == 1 || battCheckOff == 1)
- {
- counter++;
- prog = Console.ReadLine();
- continue;
- }
- int percent = int.Parse(prog.Substring(prog.Length - 3, 2));
- power = power - percent;
- if (power <= 15 && power > 0)
- {
- battCheck = 1;
- }
- else if (power <= 0)
- {
- battCheckOff = 1;
- }
- prog = Console.ReadLine();
- }
- if (battCheck == 1)
- {
- Console.WriteLine($"Connect charger -> {power}%");
- Console.WriteLine($"Programs left -> {counter}");
- }
- else if (battCheckOff == 1)
- {
- Console.WriteLine("Phone Off");
- }
- else
- {
- Console.WriteLine($"Successful complete -> {power}%");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement