Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input){
- let moneyForSinger = Number(input.shift());
- let command = input.shift();
- let counter = 0;
- let total = 0;
- while (command != "The restaurant is full")
- {
- let numberOfGuests = Number(command);
- counter += numberOfGuests;
- if (numberOfGuests < 5)
- {
- total += 100 * numberOfGuests;
- }
- else if (numberOfGuests >= 5)
- {
- total += 70 * numberOfGuests;
- }
- command = input.shift();
- }
- if (total >= moneyForSinger)
- {
- console.log(`You have ${counter} guests and ${total - moneyForSinger} leva left.`);
- }
- else
- {
- console.log(`You have ${counter} guests and ${total} leva income, but no singer.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment