Advertisement
Spocoman

11. HappyCat Parking

Jan 1st, 2022
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function happyCatParking(input) {
  2.     let days = Number(input[0]);
  3.     let hours = Number(input[1]);
  4.     let total = 0;
  5.  
  6.     for (let i = 1; i <= days; i++) {
  7.         let dayPrice = 0;
  8.        
  9.         for (let j = 1; j <= hours; j++) {
  10.  
  11.             if (i % 2 === 0 && j % 2 === 1) {
  12.                 dayPrice += 2.5;
  13.             } else if (i % 2 === 1 && j % 2 === 0) {
  14.                 dayPrice += 1.25;
  15.             } else {
  16.                 dayPrice++;
  17.             }
  18.         }
  19.         total += dayPrice;
  20.         console.log(`Day: ${i} - ${dayPrice.toFixed(2)} leva`);
  21.     }
  22.     console.log(`Total: ${total.toFixed(2)} leva`);
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement