Advertisement
Marin171

js

Oct 22nd, 2022
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. function solve(input) {
  2. let n = Number(input[0]);
  3. kol = 0;
  4. gr = 0;
  5. allKol = 0;
  6. gradus = 0;
  7. allGr = 0;
  8. totalGr = 0;
  9.  
  10. for (let i = 1; i <= n; i++) {
  11. kol = Number(input.shift());
  12. gr = Number(input.shift());
  13.  
  14. gradus = kol * gr;
  15. allKol += kol;
  16. allGr += gradus;
  17. }
  18. totalGr = allGr / allKol;
  19. console.log(`Liter: ${allKol.toFixed(2)}`);
  20. console.log(`Degrees: ${totalGr.toFixed(2)}`);
  21. if (totalGr < 38) {
  22. console.log("Not good, you should baking!");
  23. } else if (totalGr >= 38 && totalGr <= 42) {
  24. console.log("Super!");
  25. } else if (totalGr > 42) {
  26. console.log("Dilution with distilled water!");
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement