Advertisement
Spocoman

Vet Parking

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