Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

Airline seats reservation java program

05/12/2021 Client: muhammad11 Deadline: 2 Day

COMP 1020

Material covered: Please ensure that you: Part A: Airline seating Part B: Date book

Material covered:

Review of COMP 1010 (arrays and simple strings) in Part A
Creating basic classes and objects in Part B
Using arrays of objects in Part B
top

Please ensure that you:

solve all problems with programs written in the Java programming language;
follow the programming standards;
submit a separate complete program for each part that can be saved in a single Java source code file, and compiled and executed without any other Java files; and
submit your solution to both parts of the assignment by the assignment due date.
If you submit a solution that does not meet these requirements (for example, if the program does not run), you will lose some or all marks.

top

Part A: Airline seating [10 marks]

Millions of commercial airline flights cross the world's cities every year, and each one of these flights must solve what seems like a simple problem: how do you arrange where each passenger on one of those flights sits? In this assignment, we will solve a variation on that problem, where we will observe one restriction on the seats: people who book a flight together will be — if possible — seated together.

Your program will process data from an array of strings (call this the "bookings" array). The first array element will contain a number indicating how many seats the aircraft has. The remaining elements will contain information about groups of passengers who have booked seats on the flight. The first element of this grouping will be a number that indicates how many people are in the group. The remaining elements identify the individual passengers in that group by their last and first name. For example, the array might contain the following 10 strings:

8

2

Nobbly, Greg

Nobbly, Jo-Anne

1

Lee, Sook

3

Lukas, Stephie

Lukas, Cambridge

Lukas, Ogden
which means there are 8 seats on the flight, the first group of passengers has 2 people (with their names below), the second group has 1 person, and the third group has 3 people.

Normally this data would come from input, such as lines from a text file, not from an array. That's the next assignment.

The seating chart for the flight will be stored in an array of strings (call this the "seats" array), whose size is equal to the number of seats on the flight. Each position in the array corresponds to a seat on the flight; the first element in the array is seat 1, the second element is seat 2, etc. Initially all the seats are empty. Passengers will be seated by placing their name in this array.

Your program will seat passengers as follows:

It will create a "seats" array of the appropriate size (given in the first position of the "bookings" array).
It will process the remaining items in the "bookings" array of strings. For each group of passengers it will attempt to seat them as follows:
First, it will see if there are enough seats remaining on the flight for everyone in the group; if not, it will display an error message and not assign seats to anyone in the group.
Secondly, it will go through the "seats" array to determine if a block of empty seats large enough to seat the entire group together is available (for example, if the group size is 3, it will see if there are 3 consecutive empty seats).
If there is at least one such block of seats anywhere in the array, randomly assign the group to one of these blocks by randomly selecting an element in the "seats" array. If that seat is empty, determine if enough successive array elements (seats) are also empty to seat the entire group; if so, seat them there. Otherwise, randomly try another seat, repeating until successful. (Note that this is not the most efficient approach...)
If there is no such block, randomly assign each passenger in the group individually to a seat (i.e., the group will be split up). For each passenger, pick random seat numbers until you find an empty seat.
When the seats for the flight have been assigned, print the contents of the "seats" array (neatly) to the display. Show both filled and empty seats, describing empty seats as "empty" (do not display the word "null"). Label each line of output with the seat number, where the first seat on the aircraft is seat 1.

Note that using the algorithm above, passengers never move once their seat has been assigned. A group may be split up due to the result of the randomly chosen seat locations. For example, the sample data above may result in the following output:

Seat 1: Lukas, Ogden

Seat 2: Lee, Sook

Seat 3: -empty-

Seat 4: Lukas, Stephie

Seat 5: Nobbly, Greg

Seat 6: Nobbly, Jo-Anne

Seat 7: -empty-

Seat 8: Lukas, Cambridge
Because the seat assignments for the first two groups left no block of three seats empty, each person in the third group had to each be assigned a random seat. If the first two groups had been seated differently, the third group may have been able to sit together.

Your main program will seat three flights. Each flight will be described by a "bookings" array that you will pass to a method that processes the array and determines the flight seating. Call the method three times in your main program, once for each "bookings" array. Display the seating plan for each flight under an appropriate title. Note that your main program should include only declarations, assignments, method calls, and output statements (no loops or other control structures); all the processing should be performed within other methods.

This is programming standard number 18, and should be followed in all your assignments, not just this one.

First, seat the flight containing the sample data shown above (eight seats, three groups). Next, create and seat your own booking array: give the flight 12 seats, and exactly five groups containing a total of 12 passengers. Make up the passenger names. Finally, download the class Bookings.class; inside is a method public static String[] getBookings() which will return an bookings array that you should seat.

top

Part B: Date book [10 marks]

A classic computer application is the electronic date book: a list of daily events stored in a calendar. Write a Java program that can be used as a simple date book. The date book will use a separate array for each month of the year, with one array entry for each day in the month (0 = first day of the month, 1 = second day of the month, etc.). The date book is "simple" because at most one event will be allowed on each day.

Your program should include an Event class that will be instantiated for each event in the date book. The Event class consists of three instance variables: the starting time of the event (a String), the name of the event (a String), and the priority of the event (an integer value in the range 1-3, with 3 being the highest priority). Make all your instance variables private and write appropriate instance methods for processing them, including a constructor, toString(), and any others needed by your program.

Each month in the date book will be stored as an array of Events. Days with an event will point to the appropriate Event object, and days without will contain null.

Your program will produce three types of output (three views) for each month:

A calendar view, listing the days of the week (Sunday to Saturday) horizontally across the top, and the days of the month underneath. Next to each day where there is a scheduled event, print an asterisk "*". Like in a real calendar, the first day of the month can be any of the weekdays.
A list of events, showing the day of the month and the details of the event (using toString). These can be displayed in the order that they occur during the month. Do not display lines of output for days without events.
A list of the highest-priority events (those with priority 3). List only the names of the events, not the starting time or priority.
For example:

Sun Mon Tue Wed Thu Fri Sat
1 2* 3 4 5 6
7 8 9 10 11* 12* 13
14* 15* 16* 17 18 19* 20
21 22 23 24 25* 26* 27
28* 29 30

Events:
2: 4:00 PM: Event #8 (priority 3)
11: 2:00 PM: Event #10 (priority 1)
12: 5:00 PM: Event #7 (priority 3)
14: 10:00 PM: Event #2 (priority 1)
15: 6:00 PM: Event #6 (priority 3)
16: 7:00 PM: Event #5 (priority 2)
19: 3:00 PM: Event #9 (priority 2)
25: 9:00 PM: Event #3 (priority 1)
26: 11:00 PM: Event #1 (priority 3)
28: 8:00 PM: Event #4 (priority 1)

High-priority events:
2: Event #8
12: Event #7
15: Event #6
26: Event #1
Write a separate static method to generate each view. Test your program as follows:

Create two arrays of Events, september and october; the first has 30 entries, the second 31.
Place 10 events at random locations in each array. Write one method to do this, and call it twice (i.e. the two arrays will contain the same ten events on different days). Make up reasonable values for the names and starting times of the events: make them all recognizably different and meaningful (not just "Event 1", "Event 2", etc.). The method should choose a random number between 1-3 for event priority.
Display the complete output (all three views) for September. Choose the first day of the month randomly (pick a random number 0-6 where 0 is Sunday).
Display the complete output (all three views) for October. The first day of the month will be (the first day of September + 30) mod 7: that is, it will continue after September's last day.
Make sure to title both parts of your output (September and October) clearly. Remember from COMP 1010 that you can choose a random number between 1 and n using (int)(Math.random() * n) + 1.

top

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

Assignments Hut
Top Class Engineers
Financial Analyst
Professor Smith
Smart Homework Helper
Assignment Solver
Writer Writer Name Offer Chat
Assignments Hut

ONLINE

Assignments Hut

I have assisted scholars, business persons, startups, entrepreneurs, marketers, managers etc in their, pitches, presentations, market research, business plans etc.

$43 Chat With Writer
Top Class Engineers

ONLINE

Top Class Engineers

I am a PhD writer with 10 years of experience. I will be delivering high-quality, plagiarism-free work to you in the minimum amount of time. Waiting for your message.

$37 Chat With Writer
Financial Analyst

ONLINE

Financial Analyst

I am a PhD writer with 10 years of experience. I will be delivering high-quality, plagiarism-free work to you in the minimum amount of time. Waiting for your message.

$16 Chat With Writer
Professor Smith

ONLINE

Professor Smith

I can assist you in plagiarism free writing as I have already done several related projects of writing. I have a master qualification with 5 years’ experience in; Essay Writing, Case Study Writing, Report Writing.

$36 Chat With Writer
Smart Homework Helper

ONLINE

Smart Homework Helper

I have assisted scholars, business persons, startups, entrepreneurs, marketers, managers etc in their, pitches, presentations, market research, business plans etc.

$28 Chat With Writer
Assignment Solver

ONLINE

Assignment Solver

I have worked on wide variety of research papers including; Analytical research paper, Argumentative research paper, Interpretative research, experimental research etc.

$43 Chat With Writer

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

Sips panels cost per m2 australia - Trim joist span tables - Soap note review of systems example - Foodland carpet cleaner hire - Umass boston student center - Need answer for Discussion question 300 words each with 2 peer responses. - Psyc 354 homework 2 - Expressive skills vce drama - The treadmill of consumption james roberts - Confined space powerpoint presentation - KPIs - Guiding questions for biography research - Engineering national university of singapore - Cis 5 - Acara year 3 maths - Army reserve traineeship and apprenticeship program - Helen keller documentary youtube - The real leonard from awakenings - Financial accounting chapter 1 - St thomas of canterbury billingham - Why were whites stunned during the 1919 red summer riots - Leadership Applications CRJ-565-MCOL3 - College algebra - Discussion answers - Rice v great yarmouth - How to find actual size of cell - Nottingham uni degree classification - Uncollected goods left for repair - Coffee contract negotiation exercise - Diary of a wimpy kid club - Uq risk assessment database - Vce physics formula sheet 2019 - Spotlight room escape afterlight floppy 3 answer - Clearing paths to the past by kevin coyne - Onesteel hot rolled and structural steel - Jones family express comprehension questions - Case Study - 1 liter graduated cylinder - Which aspect of the following poem might imagists most admire - Begging the question fallacy advertisement - Prodelin 3.8 m antenna manual - Earth's atmosphere pie chart - Servant leadership ethics and entrepreneurism - Fear and odin in the shroud - What is the lewis structure for chloroethylene c2h3cl - Introduction to programming using python y daniel liang pdf - Pick a number double it - Rsa self service console - Cara meaning in hebrew - Learnline cdu log in - St mary's university map - Unit 1 IP Project 2 - Doubleday v kelly case summary - Design 8086 based system with following specifications - What is a lexeme - Project Management - Assignment: Evidence-Based Practice and the Quadruple Aim - John moyer sleep hypnosis - Daniel custom cycles common stock currently pays no dividends - Withdraw without academic penalty uts - Before the flood resources - The glass menagerie test questions - The century america's time over the edge video answers - Recognise and utilise diverse perspectives - Research Proposal Draft - Time of setting of hydraulic cement by vicat needle experiment - Writing help - Clownfish and anemone commensalism - Parenting a dynamic perspective 2nd edition pdf - Phases of the helping process in social work - Www jblearning com techsupport - Issa periodization - How many gb is a textbook - Service modeling in soa ppt - Smile index in orthodontics - Chateau margaux launching the third wine pdf - Ella me explicó que julián y clara - Incident response call tree - Approximately one cup of chyme is released into the small intestine every 30 seconds. - Cost accounting chapter 2 ppt - Nutts corner dog shelter - Butler lumber company pro forma balance sheet - Body glove expanse ii fins - Who is the speaker in sandburg's grass - Red seal mechanic test - Film the secret of roan inish - Illiad inc has decided to raise additional capital by issuing - Accounting Research And Write A Memo For "Fair Value Measurement” - Toucon collections - Module 1 Discussion - The solution set for 12x2 13x 3 0 is - Torbay council parking permits - Shadow health neurological assessment documentation - Preliminary investigation report sample - Home depot customer satisfaction - Visual basic 2012 programming challenges answers - Questions - Artificial Intelligence - Grant v australian knitting mills - Discussion on the “Develop a broad vision, an architecture, and a detailed plan of action that follows a life cycle concept”