Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let days = +input[0];
- let tips = +input[1];
- let lunchPrice = +input[2];
- let salary = +input[3];
- let carPrice = +input[4];
- let savings = 0;
- for (let i = 1; i <= days; i++) {
- let day = i % 7;
- if (day === 5 || day === 6) {
- savings += tips;
- } else if (day === 0) {
- savings -= tips * 2;
- } else {
- savings += tips - lunchPrice;
- }
- if (i % 15 === 0) {
- savings += salary;
- }
- if (i % 30 === 0) {
- savings -= 4 * (tips - lunchPrice);
- }
- }
- if (days % 15 === 0) {
- console.log(`George finished the season with ${savings.toFixed(2)} levs.`);
- } else {
- console.log(`George left the job with ${savings.toFixed(2)} levs.`);
- }
- if (savings >= carPrice) {
- console.log('He bought a car.');
- }
- else{
- console.log('He called for a ride home.');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement