Java Programming : A party has been organised on cruise. The party is organised for a limited time (T). The number of guests entering (E[i]) and leaving (L[i]) the party at every hour is represented as elements of the array. The task is to find the maximum number of guests present on the cruise at any given instance within T hours. Example 1: Input : 5 > Value of T [7,0,5,1,3] -> E[], Element of E[0] to E[N-1], where input each element is separated by new line [1,2,1,3,4] -> L[], Element of L[0] to L[N-1], while input each element is separate by new line. Output : 8 -> Maximum number of guests on cruise at an instance. Explanation: 1st hour: Entry 7 Exit: 1 No. of guests on ship 6 2nd hour : Entry Exit : 2 No. of guests on ship: 6-2-4 Hour 3: Entry: 5 Exit: 1 No. of guests on ship: 4+5-1-8 Hour 4: Entry 1 Exit 3 No. of guests on ship: 8+1-3-6 Hour 5: Entry 3 Exit: 4 No. of guests on ship: 6+3-4-5 Hence, the maximum number of guests within 5 hours is 8.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 12PE
icon
Related questions
Question
Java Programming :
A party has been organised on cruise. The party is organised for a limited time (T).
The number of guests entering (E[i]) and leaving (L[i]) the party at every hour is represented as elements of the array.
The task is to find the maximum number of guests present on the cruise at any given instance within T hours.
Example 1:
Input :
5 > Value of T
[7,0,5,1,3] -> E[], Element of E[0] to E[N-1], where input each element is separated by new line
[1,2,1,3,4] -> L[], Element of L[0] to L[N-1], while input each element is separate by new line.
Output :
8
-> Maximum number of guests on cruise at an instance.
Explanation:
1st hour:
Entry 7 Exit: 1
No. of guests on ship : 6
2nd hour :
Entry Exit : 2
No. of guests on ship: 6-2=4
Hour 3:
Entry: 5 Exit: 1
No. of guests on ship : 4+5-1-8
Hour 4:
Entry 1 Exit 3
No. of guests on ship: 8+1-3=6
Hour 5:
Entry 3 Exit: 4
No. of guests on ship: 6+3-4-5
Hence, the maximum number of guests within 5 hours is 8.
Transcribed Image Text:Java Programming : A party has been organised on cruise. The party is organised for a limited time (T). The number of guests entering (E[i]) and leaving (L[i]) the party at every hour is represented as elements of the array. The task is to find the maximum number of guests present on the cruise at any given instance within T hours. Example 1: Input : 5 > Value of T [7,0,5,1,3] -> E[], Element of E[0] to E[N-1], where input each element is separated by new line [1,2,1,3,4] -> L[], Element of L[0] to L[N-1], while input each element is separate by new line. Output : 8 -> Maximum number of guests on cruise at an instance. Explanation: 1st hour: Entry 7 Exit: 1 No. of guests on ship : 6 2nd hour : Entry Exit : 2 No. of guests on ship: 6-2=4 Hour 3: Entry: 5 Exit: 1 No. of guests on ship : 4+5-1-8 Hour 4: Entry 1 Exit 3 No. of guests on ship: 8+1-3=6 Hour 5: Entry 3 Exit: 4 No. of guests on ship: 6+3-4-5 Hence, the maximum number of guests within 5 hours is 8.
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT