Advertisement
ggeorgiev88

paint

Dec 13th, 2022
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function renovation(input) {
  2.     let hights = Number(input[0]);
  3.     let wide = Number(input[1]);
  4.     let noPaintPercent = Number(input[2]);
  5.     let index = 3
  6.     let littersPaintForCurrentDay = input[index];
  7.     let noPaintDecimal = noPaintPercent / 100
  8.  
  9.     let allArea = hights * wide * 4;
  10.     let allPaintArea = Math.floor(allArea - (allArea * noPaintDecimal))
  11.  
  12.     while (littersPaintForCurrentDay !== "Tired!") {
  13.         littersPaintForCurrentDay = Number(input[index]);
  14.         allPaintArea -= littersPaintForCurrentDay
  15.         if (allPaintArea > 0) {
  16.             index++
  17.             littersPaintForCurrentDay = input[index];
  18.  
  19.         } if (allPaintArea < 0) {
  20.             console.log(`All walls are painted and you have ${Math.abs(allPaintArea)} l paint left!`); return;
  21.  
  22.         }
  23.         else if (allPaintArea === 0) {
  24.             console.log("All walls are painted! Great job, Pesho!"); return;
  25.         }
  26.        
  27.  
  28.     }
  29.  
  30.     console.log(`${allPaintArea} quadratic m left.`);
  31.  
  32. }
  33.  
  34. //renovation(["3","5","10","2","3","4","Tired!"]);
  35. renovation(["2", "3", "25", "6", "7", "5"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement