Scheduling a Class (Intermediate above) You are an administrator for the Kulliyyah and is assigned the task to schedule a set of classes for a given day. Unfortunately, there is only one lecture hall and therefore, two classes cannot run at the same time. This is usually an easy task, however, there are some criteria that you would have to consider. The criteria are as follows:   ·     Each class has a duration class time. ·     Higher level courses has higher priority than other low level courses.  ·     Some lecturers prefer to have morning classes instead of the afternoon classes because they come to the office much earlier than other lecturers so they should be scheduled earlier.   Your job is to propose the best scheduling based on this criteria. To do this, you will write a C++ program that will first sort the classes by lecturer arrive time and then by course levels. Lecturers arriving early, can start first, but if they arrive at the same time, the higher level course will go first. Course 3301 for example, has higher priority than 3300 and 1100.   You will need a struct, to be defined,  as the one given below.   struct Course {    int ccode;         // course code    // class duration in military hours, 2 hours is 200 and so on    int duration;    //prefered start time 800 for 8am and 1200 for 12pm    int lecture_arrive_time;   };   Your program should output the course code with the time a class starts. We assume military time and the day starts at 800 hours and finishes at 2200 hours. If the class exceeds 2200 hours, your program should indicate that the course cannot be schedule. We also assume that there is no allocated lunch or dinner breaks.   Your program should ask for the input from the user. The input ends with 999 to indicate that there are no more classes to be scheduled.   Please enter class details.   3203 100 1500 1103 100 1500 2201 300 800 2203 100 1500 3401 200 800 1201 100 1500 999    The output should be the following:   3401 starts at 800 ends at 1000 2201 starts at 1000 ends at 1300 3203 starts at 1500 ends at 1600 2203 starts at 1600 ends at 1700 1201 starts at 1700 ends at 1800 1103 starts at 1800 ends at 1900     To help you get started, you are given with a code snippet to write your code.   #include using namespace std;   struct Course {    int ccode;         // course code    int duration;        // class duration in military hours, so 2 hours is 200 an so on    int lecture_arrive_time;   //prefered start time 800 for 8am and 1200 for 12pm };   void print_sched(Course c[],int); void class_sort(Course c[],int);   int main() {   int input=0,i=0;   Course classes[100];   cout << "Please enter class details:" << endl;   cin >> input;   while (input != 999){     classes[i].ccode = input;     cin >> classes[i].duration;     cin >> classes[i].lecture_arrive_time;     i++;     cin >> input;   }   class_sort(classes, i);   print_sched(classes, i); }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Scheduling a Class (Intermediate above)

You are an administrator for the Kulliyyah and is assigned the task to schedule a set of classes for a given day. Unfortunately, there is only one lecture hall and therefore, two classes cannot run at the same time. This is usually an easy task, however, there are some criteria that you would have to consider. The criteria are as follows:

 

·     Each class has a duration class time.

·     Higher level courses has higher priority than other low level courses. 

·     Some lecturers prefer to have morning classes instead of the afternoon classes because they come to the office much earlier than other lecturers so they should be scheduled earlier.

 

Your job is to propose the best scheduling based on this criteria. To do this, you will write a C++ program that will first sort the classes by lecturer arrive time and then by course levels. Lecturers arriving early, can start first, but if they arrive at the same time, the higher level course will go first. Course 3301 for example, has higher priority than 3300 and 1100.

 

You will need a struct, to be defined,  as the one given below.

 

struct Course

{

   int ccode;         // course code

   // class duration in military hours, 2 hours is 200 and so on

   int duration;

   //prefered start time 800 for 8am and 1200 for 12pm

   int lecture_arrive_time;  

};

 

Your program should output the course code with the time a class starts.

We assume military time and the day starts at 800 hours and finishes at 2200 hours. If the class exceeds 2200 hours, your program should indicate that the course cannot be schedule. We also assume that there is no allocated lunch or dinner breaks.

 

Your program should ask for the input from the user. The input ends with 999 to indicate that there are no more classes to be scheduled.

 

Please enter class details.

 

3203 100 1500

1103 100 1500

2201 300 800

2203 100 1500

3401 200 800

1201 100 1500

999 

 

The output should be the following:

 

3401 starts at 800 ends at 1000

2201 starts at 1000 ends at 1300

3203 starts at 1500 ends at 1600

2203 starts at 1600 ends at 1700

1201 starts at 1700 ends at 1800

1103 starts at 1800 ends at 1900

 

 

To help you get started, you are given with a code snippet to write your code.

 

#include <iostream>

using namespace std;

 

struct Course

{

   int ccode;         // course code

   int duration;        // class duration in military hours, so 2 hours is 200 an so on

   int lecture_arrive_time;   //prefered start time 800 for 8am and 1200 for 12pm

};

 

void print_sched(Course c[],int);

void class_sort(Course c[],int);

 

int main()

{

  int input=0,i=0;

  Course classes[100];

  cout << "Please enter class details:" << endl;

  cin >> input;

  while (input != 999){

    classes[i].ccode = input;

    cin >> classes[i].duration;

    cin >> classes[i].lecture_arrive_time;

    i++;

    cin >> input;

  }

  class_sort(classes, i);

  print_sched(classes, i);

}

 

** you will need to implement the functions **

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY