Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Program 3 will be a \"multiple choice\" program. By that I mean that you can cho

ID: 3833990 • Letter: P

Question

Program 3 will be a "multiple choice" program. By that I mean that you can choose to do the "simpler" option of scheduling CSCE classes into available classrooms OR, you can, if you wish try a more difficult task of scheduling not only classes into rooms but also individual students into classes as well. If you choose the simpler version, your maximum score will be 100.    If you choose the more difficult version, you COULD get a score of 200 points.

So, let's start with the simple case. Your program should read (from standard input using redirected file I/O) an input file in the following format. (Please use redirected input!, the following class and room list is what is in the input file! and a student part may need to be added as well, Do not have the user input classes, rooms, etc., Also if possible, please do the add to students to class aswell, prefer whole program using linked list)

Classes
    1030 435
    1040 345
    2100 97
    2110 159

Rooms
    B185 130
    B192 48
    B142 48
    B140 48

More specifically, you'll read a list of class numbers, followed by the number of students expected to sign up for the course AND a list of rooms, followed by the number of students we can include in that room.

Your output should be in a form that it easy to read. For example you might list the days of the week and times of day in a table with the class and room number listed for each class. The output format is for YOU to choose, but it WILL be evaluated on how easy it is for the TA to read it.    Also, since there will be many possible correct schedules your program will be graded on the number of class periods your schedule requires, with a smaller number of schedule slots used getting more points.

Write your program in C++ and submit (to this "page") all of your code. We will compile your code using the following commands.

               g++ *.cpp

             ./a.out < ourInputFile

Explanation / Answer

We will plan a timetable in such a way that the number of periods are minimized per day.

Total number of students enrolled = 1636

Total accomodation in classroom in 1 period = 130+48+48+48=274

The minimum number of periods required are:
1636/274 =5.97 or approximately 6.

We will try to keep our answer closest to 6 and hence minimize the value.

Now since there are four classrooms, simultaneously 4 classes can be taken.

#include<iostream>
#include<string>
#include<fstream>

//global definition of all the class names, capacities and classroom names
/*int classesname[]={1030, 1040, 2100, 2110};
string classroomname[]={"B185", "B192", "B142", "B140"};
int classes[]={435, 345, 97, 159};
int classroom[]={130, 48, 48, 48};
node timetable[4][10];
int result=INT_MAX; */

using namespace std;
struct node
{
int iclass;
string room;
};

void check_for_students(int[] students_left)
{
for(int i=0; i<4; i++)
if(students_left[i]>0)
return false;
return true;
}

void calculate_timetable(int[] students_left, int periods)
{
if(check_for_students(students_left)) //function to check if all the students have been assigned to some classroom or not in a day
{
if(result>periods)
result=periods //update the result to minimize the result
return;
}
for(int i=0 i<4; i++)
{
for(int k=0; k<4; k++)
{
timetable[i][periods]=min(students_left[k], classroom[i]); //check for all the combinations of classroom allocations and class names using DFS
students_left[k]-=timetable[i][periods]; // keep updating the timetable array to keep the record of the class name and classroom allocation
calculate_timetable(students_left, periods);
students_left[k]+=timetable[i][periods];
}
}
calculate_timetable(students_left, periods++);
}

int main()
{
ofstream myfile.open("input.txt");
int students_left[]={435, 345, 97, 159};
calculate_timetable(students_left, 0);
for(int i=0; i<4; ++)
{
for(int j=0; j<result; j++)
{
cout<<timetable[i][j]<<" ";
}
cout<<endl;
}
myfile.close();
return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote