Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function grandpaStavri(input) {
- let days = Number(input[0]);
- let totalLiters = 0;
- let averageGradus = 0;
- for (let i = 1; i <= days * 2; i++) {
- let liters = Number(input[i++]);
- let gradus = Number(input[i]);
- totalLiters += liters;
- averageGradus += liters * gradus;
- }
- console.log(`Liter: ${totalLiters.toFixed(2)}`);
- console.log(`Degrees: ${(averageGradus / totalLiters).toFixed(2)}`);
- if (averageGradus < 38) {
- console.log("Not good, you should baking!");
- } else if (averageGradus <= 42) {
- console.log("Super!");
- } else {
- console.log("Dilution with distilled water!");
- }
- }
- РЕШЕНИЕ СЪС SHIFT() И ТЕРНАРЕН ОПЕРАТОР:
- function grandpaStavri(input) {
- let days = Number(input.shift());
- let totalLiters = 0;
- let averageGradus = 0;
- for(let i = 0; i < days; i++) {
- let liters = Number(input.shift());
- let gradus = Number(input.shift());
- totalLiters += liters;
- averageGradus += liters * gradus;
- }
- console.log(`Liter: ${totalLiters.toFixed(2)}`);
- console.log(`Degrees: ${(averageGradus / totalLiters).toFixed(2)}`);
- console.log( averageGradus < 38? "Not good, you should baking!" : averageGradus <= 42 ? "Super!" : "Dilution with distilled water!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement