Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- List<Integer> cellsPuttedOut = new ArrayList<>();
- int totalFire = 0;
- double effort = 0.00;
- int value = 0;
- String type = "";
- String input = scanner.nextLine();
- int water = Integer.parseInt(scanner.nextLine());
- String[] firstSplit = input.split("[#]+");
- System.out.println();
- for (int i = 0; i < firstSplit.length; i++) {
- String[] typeAndValue = firstSplit[i].split("[ = ]+");
- type = typeAndValue[0];
- value = Integer.parseInt(typeAndValue[1]);
- if (water <= 0 )
- {
- break;
- }
- if (water < value){
- continue;
- }
- if (type.equals("High" ) && (value >=81 && value <= 125)){
- water -= value;
- totalFire += value;
- effort = effort + (value * 0.25);
- cellsPuttedOut.add(value);
- }
- if (type.equals("Medium") && (value >=51 && value <= 80)){
- water -= value;
- totalFire += value;
- effort = effort + (value * 0.25);
- cellsPuttedOut.add(value);
- }
- if (type.equals("Low") && (value >=1 && value <= 50)){
- water -= value;
- totalFire += value;
- effort = effort + (value * 0.25);
- cellsPuttedOut.add(value);
- }
- }
- System.out.println("Cells:");
- for (int i = 0; i < cellsPuttedOut.size(); i++) {
- System.out.printf("- %d\n",cellsPuttedOut.get(i));
- }
- System.out.printf("Effort: %.2f\n",effort);
- System.out.printf("Total Fire: %d",totalFire);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement