Question
Assignment 1 Instructions: Your assessment will be tested using Visual Studio Code. In addition to implementing the required functionality, grading is based on appropriate usage
Assignment 1
Instructions:
Your assessment will be tested using Visual Studio Code.
In addition to implementing the required functionality, grading is based on appropriate usage of coding conventions demonstrated in class, clear organization of code, clarity of variable naming, etc.
You must use let/const when declaring variables
Functions must be declared using arrow syntax
Submission Checklist:
Create a Javascript le containing your solution.
Rename your Javascript le: Flights-rstname.js. Replace rst name with your rst name..
Example: Flights-Jennifer.js
Submit your le to the assessment dropbox
Academic Integrity
You are responsible for familiarizing yourself with the colleges Academic Integrity Policy.
Actions that constitute academic dishonesty include, but are not limited to:
Reposting any part of the assessment to online forums or homework help websites
Contract plagiarism: Purchasing a solution, or completing a solution for nancial compensation
Sharing or receiving source code, references, or assistance from others
Problem Description:
You were hired by an airline company to build an application that manages the companys ight offerings. Using Javascript, you are to create a console based application per the specications below.
In the below descriptions, a ight object refers to a Javascript object literal that represents a ight offered by the company. Every ight has a ight number (string), departure airport (string), arrival airport (string), distance (number) and number of available seats (number).
Create the following functions.
showFlight(flight): The function accepts a single ight object literal and returns a String containing information about the ight, as follows:
Flight NA255, departing STL and arriving TPE. Seats Remaining: 30
searchByCity(city, listOfFlights): This function accepts a city name and an array of ight objects. The function should search the array of ights and return an array of ights departing from the specied city. If no matching ights are found, then the function should return an empty array. Your implementation must use the .lter() function.
updateFlights(listOfFlights, hasCapacityLimit): This function accepts an array of ight objects and a boolean variable called hasCapacityLimit. The function should iterate through the list of ights and modify the number of available seats on each ight.
If hasCapacityLimit is true, then the available number of seats on each ight should be decreased by 20%. If hasCapacityLimit is false, then the number of available seats should be increased by 50%.
After adjusting the seat numbers, the function should return an array of ight objects containing the updated seat information.
Your implementation must use the .map() function.
showStats(listOfFlights): This function accepts an array of ight object literals and returns an new object containing the following information:
Number of ights: The total number of ights operated by the airline.
Total revenue: The total revenue the airline can expect to generate if they sell every seat on every ight. The cost of an individual seat is calculated as follows: $100 + distance charge. The distance charge is computed at $0.35 per mile.
Your implementation of calculating total revenue must use the .reduce() function.
HINT: When applying reduce() to an array of objects, you need to provide an initial value for the reduce functions accumulator variable. For this example, consider setting the initial value to 0.
After creating these functions, write a program that performs the following operations. Where possible, you must use the showAll, searchByCity, update city, and showStats functions.
When writing your code for the program, please ensure you use appropriate whitespacing, informative messaging, and symbols to clearly indicate what your program is doing (see
sample output on next page).
List of Operations
Using the table data below, create an array of ight object literals:
Flight Number
Departure City
Arrival City
Distance
Available Seats
NA255
STL
TPE
7589
30
NA421
STL
FCO
5065
1
NA100
AKL
ZQN
636
10
NA918
NRT
ITM
306
6
Using your array of ight literals and the searchByCity function, search for ights departing STL. If ights are found, loop through the matched ights and output information about each ight. If no ights are found, display a message: No ights found.
The airline company wants to run projections on how changes to their ight offerings will affect their revenue numbers. The two options the company wants to consider are:
OPTION A: Imposing a capacity limit on the current list of ight offerings
OPTION B: Removing the last ight in the array and imposing a capacity limit on all remaining ights. You are NOT permitted to statically code the position of the last item in the array.
Using the updateStats and showStats functions, compare how implementing Option A and Option B affect the companys overall revenue. Specically, your code should output the following information:
Given the original list of ights, output the total number of ights and the total revenue the company can expect to earn if they sell every seat on the ight.
Output the total number of ights and revenue earned if Option A were implemented. Also, output the revenue difference between the original ights and Option A as a percentage (%)
Output the total number of ights and revenue earned if Option B were implemented. Also, output the revenue difference between the original ights and Option B as a percentage (%)
Use the following formula for calculating percentage difference:
(new value - old value) / ( [new value + old value] / 2) x 100
Sample output
When writing your code for the program, please ensure you use appropriate whitespacing,, informative messaging, and symbols to clearly indicate what your program is doing.
For example:
Flights departing STL
Flight NA225, departing STL and arriving TPE. Seats Remaining: 30 Flight NA421, departing STL and arriving FCO. Seats Remaining: 1
Revenue Projections
Total number of flights offered is: 4 Current revenue is: $89025.85
OPTION A: Capacity Limits Applied:
Total number of flights offered is: 4 Current revenue is: $71220.68
Difference: -22.22%
OPTION B: Flight removed and no capacity limits:
Total number of flights offered is: 3 Current revenue is: $105339.90
Difference: 16.79%
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started