Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.Scanner;
- public class SeizeTheFire {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String[] fireCells = scanner.nextLine().split("\\#+");
- int water = Integer.parseInt(scanner.nextLine());
- String fireType = "";
- int fireValue = 0;
- double totalEffort = 0;
- int totalWater=0;
- double totalCellsSpended=0;
- for (int i = 0; i < fireCells.length ; i++) {
- String [] currentFire = fireCells[i].split("\\s+\\= ");
- fireType=currentFire[0];
- fireValue=Integer.parseInt(currentFire[1]);
- if (fireTypeValidation(fireType, fireValue)){
- effortCalculator(fireValue,totalEffort);
- waterSpending(water,fireValue,totalWater);
- totalCells(fireValue,totalCellsSpended);
- }
- }
- }
- static boolean fireTypeValidation (String fireType, int fireValue){
- boolean correctType = false;
- if (fireType.equalsIgnoreCase("high")) {
- if (81 <= fireValue && fireValue <= 125) {
- correctType = true;
- }
- } else if (fireType.equalsIgnoreCase("medium")) {
- if (51 <= fireValue && fireValue <= 80) {
- correctType = true;
- }
- } else if (fireType.equalsIgnoreCase("low")) {
- if (1 <= fireValue && fireValue <= 50) {
- correctType = true;
- }
- }
- return correctType;
- }
- static void effortCalculator (int fireValue,double totalEffort){
- double effort = fireValue*0.25;
- totalEffort+= effort;
- }
- static void waterSpending (int water, int fireValue, int totalWater){
- totalWater = water-fireValue;
- }
- static void totalCells (int fireValue,double totalCellsSpended){
- totalCellsSpended=+fireValue;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement