Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. Write a C++ program (or Java program) called hw1_2.cpp (or hw1_2.java) that reads the time information of events in a convention center and displays

5. Write a C++ program (or Java program) called hw1_2.cpp (or hw1_2.java) that reads the time information of events in a convention center and displays the maximum number of concurrent events in the convention center.

Input format: This is a sample input from a user.

3

6 11

14 20

13 17

The first number (= 3 in the example) indicates that there are three event in the convention center. Then, the following lines are the time information (= start and ending hours) of each event. For example, the second line 6 11 indicates that there is an event which starts at 6:00(AM) and finishes at 11:00(AM). The next line indicates that there is an event from 2:00(PM) (= 14:00) to 8:00(PM) (= 20:00). The last event is from 1:00(PM) to 5:00(PM). In the homework, you should display the maximum number of events that can occur at the same time. For the input, your result should be 2 because the second and third events will happen at the same time from 2:00(PM) to 5:00(PM). For the homework, you can assume that the hour information always uses a positive integer from 0 to 23.

Sample Run 1: Assume that a user typed the following lines

3

6 11

14 20

13 17

This is the correct output.

Answer:2

Sample Run 2: Assume that a user typed the following lines

4

10 15

10 12

9 10

8 9

This is the correct output. Note that there are three events at 10:00(AM).

Answer:3

Sample Run 3: Assume that a user typed the following lines

4

10 12

2 9

13 17

18 23

This is the correct output.

Answer:1

Hint: Pay attention to the starting and ending hours. Also, sorting and a counter will be useful.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

More Books

Students also viewed these Databases questions

Question

an element of formality in the workplace between different levels;

Answered: 1 week ago