Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CounterStrike {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int energy = Integer.parseInt(sc.nextLine());
- int count = 0;
- String input;
- while (!"End of battle".equals(input = sc.nextLine())){
- int distance = Integer.parseInt(input);
- if (energy < distance){
- System.out.printf("Not enough energy! Game ends with %d won battles and %d energy", count, energy);
- break;
- }
- energy -= distance;
- count++;
- if (count % 3 == 0){
- energy += count;
- }
- }
- if ("End of battle".equals(input)){
- System.out.printf("Won battles: %d. Energy left: %d", count, energy);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment