Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4. public class SeizeTheFire {
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. String[] fireCells = scanner.nextLine().split("\\#+");
  9. int water = Integer.parseInt(scanner.nextLine());
  10. String fireType = "";
  11. int fireValue = 0;
  12. double totalEffort = 0;
  13. int totalWater=water;
  14. double totalCellsSpended=0;
  15.  
  16.  
  17. for (int i = 0; i < fireCells.length ; i++) {
  18. String [] currentFire = fireCells[i].split("\\s+\\= ");
  19. fireType=currentFire[0];
  20. fireValue=Integer.parseInt(currentFire[1]);
  21.  
  22. if (fireTypeValidation(fireType, fireValue)){
  23. effortCalculator(fireValue,totalEffort);
  24. waterSpending(totalWater,fireValue);
  25. totalCells(fireValue,totalCellsSpended);
  26. }
  27. }
  28. }
  29.  
  30.  
  31. static boolean fireTypeValidation (String fireType, int fireValue){
  32. boolean correctType = false;
  33.  
  34. if (fireType.equalsIgnoreCase("high")) {
  35. if (81 <= fireValue && fireValue <= 125) {
  36. correctType = true;
  37. }
  38. } else if (fireType.equalsIgnoreCase("medium")) {
  39. if (51 <= fireValue && fireValue <= 80) {
  40. correctType = true;
  41. }
  42. } else if (fireType.equalsIgnoreCase("low")) {
  43. if (1 <= fireValue && fireValue <= 50) {
  44. correctType = true;
  45. }
  46. }
  47. return correctType;
  48. }
  49.  
  50.  
  51.  
  52. static void effortCalculator (int fireValue,double totalEffort){
  53. double effort = fireValue*0.25;
  54. totalEffort+= effort;
  55. }
  56.  
  57. static void waterSpending (int totalWater, int fireValue){
  58. totalWater -= fireValue;
  59. }
  60.  
  61. static void totalCells (int fireValue,double totalCellsSpended){
  62. totalCellsSpended=+fireValue;
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement