Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 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=0;
  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(water,fireValue,totalWater);
  25. totalCells(fireValue,totalCellsSpended);
  26. }
  27.  
  28. }
  29.  
  30.  
  31. }
  32.  
  33. static boolean fireTypeValidation (String fireType, int fireValue){
  34. boolean correctType = false;
  35.  
  36. if (fireType.equalsIgnoreCase("high")) {
  37. if (81 <= fireValue && fireValue <= 125) {
  38. correctType = true;
  39. }
  40. } else if (fireType.equalsIgnoreCase("medium")) {
  41. if (51 <= fireValue && fireValue <= 80) {
  42. correctType = true;
  43. }
  44. } else if (fireType.equalsIgnoreCase("low")) {
  45. if (1 <= fireValue && fireValue <= 50) {
  46. correctType = true;
  47. }
  48. }
  49. return correctType;
  50. }
  51.  
  52.  
  53. static void effortCalculator (int fireValue,double totalEffort){
  54. double effort = fireValue*0.25;
  55. totalEffort+= effort;
  56. }
  57.  
  58. static void waterSpending (int water, int fireValue, int totalWater){
  59. totalWater = water-fireValue;
  60. }
  61.  
  62. static void totalCells (int fireValue,double totalCellsSpended){
  63. totalCellsSpended=+fireValue;
  64. }
  65.  
  66.  
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement