Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function computerRoom(input) {
- let season = input.shift();
- let spendingTime = Number(input.shift());
- let people = Number(input.shift());
- let dayOrNitght = input.shift();
- let pricePerPerson = 0;
- let totalCost = 0;
- let currentPricePerPerson = 0;
- if (season == 'march' || season == 'april' || season == 'may') {
- if (dayOrNitght == 'day') {
- if (people >= 4) {
- currentPricePerPerson = 10.50 * .90;
- } else currentPricePerPerson = 10.50;
- } else {
- if (people >= 4) {
- currentPricePerPerson = 8.40 * .90;
- } else {
- currentPricePerPerson = 8.40;
- }
- }
- } else if (season == 'june' || season == 'july' || season == 'august') {
- if (dayOrNitght == 'day') {
- if (people >= 4) {
- currentPricePerPerson = 12.60 * .90;
- } else currentPricePerPerson = 12.60;
- } else {
- if (people >= 4) {
- currentPricePerPerson = 10.20 * .90;
- } else {
- currentPricePerPerson = 10.20;
- }
- }
- }
- if (spendingTime >= 5){
- pricePerPerson = currentPricePerPerson * 0.5;
- } else {
- pricePerPerson = currentPricePerPerson;
- }
- totalCost = pricePerPerson * spendingTime * people;
- console.log(`Price per person for one hour: ${pricePerPerson.toFixed(2)}`);
- console.log(`Total cost of the visit: ${totalCost.toFixed(2)}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement