Advertisement
MartenBG

Untitled

Feb 21st, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. function computerRoom(input) {
  2. let season = input.shift();
  3. let spendingTime = Number(input.shift());
  4. let people = Number(input.shift());
  5. let dayOrNitght = input.shift();
  6. let pricePerPerson = 0;
  7. let totalCost = 0;
  8. let currentPricePerPerson = 0;
  9.  
  10. if (season == 'march' || season == 'april' || season == 'may') {
  11. if (dayOrNitght == 'day') {
  12. if (people >= 4) {
  13. currentPricePerPerson = 10.50 * .90;
  14. } else currentPricePerPerson = 10.50;
  15. } else {
  16. if (people >= 4) {
  17. currentPricePerPerson = 8.40 * .90;
  18. } else {
  19. currentPricePerPerson = 8.40;
  20. }
  21. }
  22. } else if (season == 'june' || season == 'july' || season == 'august') {
  23.  
  24. if (dayOrNitght == 'day') {
  25. if (people >= 4) {
  26. currentPricePerPerson = 12.60 * .90;
  27. } else currentPricePerPerson = 12.60;
  28. } else {
  29. if (people >= 4) {
  30. currentPricePerPerson = 10.20 * .90;
  31. } else {
  32. currentPricePerPerson = 10.20;
  33. }
  34. }
  35. }
  36. if (spendingTime >= 5){
  37. pricePerPerson = currentPricePerPerson * 0.5;
  38. } else {
  39. pricePerPerson = currentPricePerPerson;
  40. }
  41. totalCost = pricePerPerson * spendingTime * people;
  42. console.log(`Price per person for one hour: ${pricePerPerson.toFixed(2)}`);
  43. console.log(`Total cost of the visit: ${totalCost.toFixed(2)}`);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement