build a scheduling system to support their degree program in JAVA 18

User Generated

qybyn1990

Programming

Saginaw Valley State University

Description

-A console would be fine.

- There should be 4 tables

- Get the basic database working first, then start adding functionality and the UI. The UI should be the last thing that you worry about and it doesn't even have to be graphical - it just needs to provide the required reporting!

Unformatted Attachment Preview

Start this assignment today and build it incrementally. Get the basic database working first, then start adding functionality and the UI. The UI should be the last thing that you worry about and it doesn't even have to be graphical - it just needs to provide the required reporting! Have fun, good luck and be prepared to work hard and learn a lot! Don't wait just because I've given you a large chunk of time - this program will bury you if you don't get going!! You have been warned!!!!Note: in any given semester, there could be multiple sections of a particular course ID offered, e.g. there could be 4 sections of CSC 116 which would appear in the schedule as CSC 116-01, CSC 116-02, CSC 116- 03 and CSC 116-04. The section numbering would increment based on how each section is found in the input file. Here are the scheduling rules your program must implement: • Classes are scheduled on a first come, first serve basis. The first record in the text file gets scheduled, then the second record and so on. • • • • 4 credit classes are typically broken into MW or TR in two hour blocks. The available times are 8:30-10:30, 10:30-12:30, 12:30-2:30 and 2:30-4:30. The two hour blocks must be scheduled in the same classroom on both days. 3 credit classes are typically broken into MW or TR in one and a half hour blocks. The available times are 9:00-10:30, 10:00-11:30, 11:00-12:30, 12:00-1:30, 1:00-2:30, 2:00-3:30 and 3:00-4:30. The one and a half hour blocks must be scheduled in the same classroom on both days. 2 credit classes and 1 credit classes are typically scheduled on a single day (M through R) and may start at any hour mark between 9:00 and 3:00 for 1 credit classes and start at any hour mark between 9:00 and 2:00 for 2 credit classes. The entirety of the course must be scheduled in a single classroom, e.g. for a 2 credit class it cannot be scheduled for 1 hour in Classroom B and then 1 hour in Classroom A. When examining open classrooms at a particular day/time set, start with Classroom A, then B and finally C. If a requested 4 credit or 3 credit day/time set is not available, first examine if the time slot on the opposite days of the week is available, if it is, schedule the class there. For example, let's say that there are no classrooms available on a requested MW 12:30-2:30, then check to see if a TR 12:30-2:30 classroom is available, if it is, schedule the class there. Likewise, if a requested TR time is full, check the MW time to see if it is available. о о If the adjacent days did not yield an open classroom, then continue moving in time blocks after the original requested time on the original days to try to find an open classroom. Assuming we were to place a class on MW at 12:30-2:30 and it wasn't available, nor was TR at 12:30-2:30, then we would next look at MW 2:30-4:30, if it's not available, move on to TR 8:30-10:30, then TR 10:30-12:30 and so on. You may end up having to "loop around" to previous times, e.g. MW 8:30-10:30 and MW 10:30-12:30 in our case, but those would be the last two resorts for the 2 hour blocks. If no classroom placement could be found on the two day MW or TR split, then look to see if an appropriate 4 hour or 3 hour block can be found on Friday and schedule the class there. Nobody wants to work on Fridays, so the scheduling works differently... Friday classes start on the half hour mark for 4 credit classes with the earliest being 8:30 and the latest starting at 12:30 (so times like 9:30, 10:30, 11:30, et cetera are all valid starting times). Three credit classes start on the hour mark with the earliest 3 credit starting at 9:00 and the latest starting at 1:00 (the school wants all classes ended by 4:30). The entirety of any Friday class must be scheduled in a single classroom. If an available Friday slot cannot be found either, then list the class as unable to be scheduled. Make sure that you do give the unscheduled classes a sequential section number since they will have to be addressed by the administration.2 credit and 1 credit classes will follow a simplified scheduling process: if the requested day/time is unavailable, continue moving forward in time blocks after the original requested day/time to try to find an open classroom. Don't forget the loop around. If nothing can be found M through R, then look at Friday for a spot. Both 1 and 2 credit Friday classes start on the hour mark, with the earliest start time being 9:00 a.m. and the latest class ending at 4:00. If nothing is available on Friday, then list the class as unable to be scheduled (again with a section number). We do not try to look at the "opposite days" at the same time, like we do for 4 and 3 credit classes since these are not split across two days. While you may think this is a tough scheduling problem, it's really simplified. It doesn't take any of the following into account, which an actual class scheduler would need to worry about: Faculty could end up with more than one class to teach at the same time. This really makes things much more messy, so we'll just pretend that faculty can clone themselves to cover any conflicting classes they might get assigned. Classes blocking students from taking what they need. Let's say that students are supposed to take both CSC 316 Data Structures and CSC 412 Sensor Systems in the same semester. In reality we would have to make sure that those two classes do not end up being offered at the same time to where a student would have to choose between one or the other. Prerequisites are not considered. This is very similar to what we just mentioned in that not only do we need to make sure certain classes are not blocked for students, we also need to have some knowledge that certain classes can be taught at the same day/time in different classrooms without a problem. For example, you would not have a student taking both CSC 116 Programming I and CSC 216 Programming II at the same time since 116 is a prereq for 216. Therefore scheduling CSC 116 in Classroom A on MW 8:30-10:30 and CSC 216 in Classroom B on MW 8:30-10:30 is not problematic. I am also presenting good data files, e.g. when a specific course request is being made, it is formatted properly and doesn't contain bad course ID values, faculty names, invalid days/times and has the requested times formatted correctly for the number of credit hours. All input files will be text based. Each piece of data will be tab delimited and each line will be terminated with a carriage return/line feed combination. Here is a sample of the first few lines from JITClasses.txt: CSC 105 CSC 105 James MW Smith MW 8:30 10:30 8:30 10:30 Each line contains a course scheduling request. Line 1 is requesting that a section of CSC 105 be scheduled in a classroom on MW from 8:30 to 10:30 (this would be section 01 of that class) for instructor James. Line 2 is requesting that a section of CSC 105 also be scheduled in a classroom on MW from 8:30 to 10:30 for instructor Smith (this would be CSC 105-02). What's requested may not be available, so this is where your scheduler program comes in.CS 421 - Assignment 3 You have been hired by the James Institute of Technology to build a scheduling system to support their degree program. The school offers one degree in computer science so, believe it or not, that should make things a little bit easier. Currently there are 6 faculty members (James, Smith, Jones, Vasquez, Abdul and Thomas) that make up the teaching staff. The school also has three classrooms available with varying numbers of seats: Classroom A can hold 30 students, Classroom B can hold 25 students and Classroom C can hold 20 students. The current course catalog consists of the following classes in the computer science program: Course ID Course Title CSC 105 CSC 107 Computers and Programming Introduction to Code Preparation CSC 116 Programming | CSC 216 CSC 227 CSC 316 Data Structures & Algorithms CSC 416 CSC 211 CSC 311 CSC 313 Programming II Commenting and Naming Conventions Advanced Algorithm Analysis Introductory .NET Development Advanced .NET Development Real World Application Development CSC 411 Data Driven Systems CSC 412 Sensor Systems CSC 413 Artificial Intelligence Systems CSC 496 Software Engineering I CSC 497 Software Engineering II CSC 498 Software Engineering III Credit Hours 4 1 4 4 2 4 3 3 4 3 3 3 3 4 4 4 You need to write a scheduling program that will store the results in a SQLite database determining an optimal schedule based on the scheduling rules which are provided below. When your program is run for the first time, it will construct the database schema from scratch using DDL and prepopulate tables that we will collectively develop in class using DML. [This allows me consistency when I attempt to grade your assignment.] Your program will then prompt me for a text file to use as an input containing classes to schedule. The initial set of records that I want scheduled are located in JITClasses.txt. You will schedule those classes, and once completed, allow me to view 3 reports (schedule by day/time; schedule by faculty member with total credit hours being taught by each faculty member; and schedule by class, listing all sections and total student capacity for that class). I then should have the option to load an additional data file containing additional classes to add to the current schedule. Once that file is scheduled, I can view the reports again. This will continue until I tell your program that I am finished. Prior to shutting the application down, you should give me the option of completely deleting the database or leaving it intact. I will want to view the raw SQLite file, so this is a requirement. If the SQLite file exists on a subsequent run of your program, you should ask whether the database should be reset to its initial base state.Continue Schedule table Start-time End-time Days 9:00 11:00 10.00 W 12:00 M 2 * Exception of Schedus Can't be Scheduled. 410Continue Schedule table Start-time End-time Days 9:00 11:00 10.00 W 12:00 M 2 * Exception of Schedus Can't be Scheduled. 410Table Unique identifier Courses table *primanj Key Course ID 7 This allto-generate No abbrev. (write the whole \TUD | Course ID / Course Title thing) Creat hours CSC 105 Computes and programming 4 2 CSG 107 introduction to code preparation 1 +1 hour 3 CSC 116 T प professor Table TUID professor Name ' James 2 Smith Classwom Table TUID 2 3 Au separate Unities -Do you want to reset the data-base? - Do you want to erase I classroom Nume capacity. A B C → primary Kay Schedule table 30 25 20 different sections TUID Course-TUID Section Classroom TUID Professur TUD 2 22 1 3 2 2 Association table.
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

View attached explanation and answer. Let me know if you have any questions.I've added a screenshot for your reference of how to run the program, and I've added comments alongside the code to explain what each part is supposed to do.
View attached explanation and answer. Let me know if you have any questions.I made a small edit, please use this versionhttps://clipchamp.com/watch/tYRvz4L7PkF
View attached explanation and answer. Let me know if you have any questions.I figured out a way to print schedules neatly, I edited it and it prints well formatted tables now

// Need SQLite Driver from
// https://github.com/xerial/sqlite-jdbc/releases

// Compiled with javac Schedule.java
// Executed with java -classpath ".;sqlite-jdbc-3.39.3.0.jar" Schedule


import java.io.File;
import java.io.FileInputStream;
import java.sql.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
import java.util.TimeZone;


public class Schedule {

// slot class to store one slot information
static class Slot {
Time startTime = null;
Time endTime = null;
Integer room = null;
String days = null;
}

// database file name
final static String DBfileName = "JITscheduleCS.db";

// connection object to be used to interact with the database
static Connection con;

// time zone offset of local time from UTC
final static long tzOffset = TimeZone.getDefault().getOffset(new Date().getTime());

// constant to transform hours to milliseconds
final static long hours2millisecond = 60*60*1000;

// starting time of the last slot depending on the credit hours
// 4 credits, 3 credits, 2 credits, 1 credits
final static Time[] lastSlot = {new Time((long) (14.5 * hours2millisecond - tzOffset)),
new Time(15 * hours2millisecond - tzOffset),
new Time(14 * hours2millisecond - tzOffset),
new Time(15 * hours2millisecond - tzOffset)};

// starting time of the first slot depending on the credit hours
// 4 credits, 3 credits, 2 credits, 1 credits
final static Time[] firstSlot = {new Time((long) (8.5 * hours2millisecond - tzOffset)),
new Time(9 * hours2millisecond - tzOffset),
new Time(9 * hours2millisecond - tzOffset),
new Time(9 * hours2millisecond - tzOffset)};

// number of hours between each slot depending on the credit hours
// 4 credits, 3 credits, 2 credits, 1 credits
final static int[] hours = {2, 1, 1, 1};

// establish database connection
private static Connection getConnection()
throws ClassNotFoundException, SQLException {
Connection con;
// Database path -- if its new database, it will be created in the project folder
con = DriverManager.getConnection("jdbc:sqlite:"+DBfileName);
return con;
}

// build database tables and populate rows
private static void buildDatabase (boolean load)
throws ClassNotFoundException, SQLException {

Statement state;
ResultSet res;
PreparedStatement prep;

// Check for database table existence and if it's not there, create it and populate records
state = Schedule.con.createStatement();
res = state.executeQuery("SELECT name FROM sqlite_master WHERE type='table' AND name='Course_Table'");
if (!res.next()) {
System.out.println("Building the Courses table");
state = Schedule.con.createStatement();

state.executeUpdate("CREATE TABLE Course_Table(" +
"TUID INTEGER," +
"Course_ID VARCHAR(8)," +
"Course_Title VARCHAR(60)," +
"Credit_Hours INTEGER," +
"PRIMARY KEY (TUID));");

System.out.println("Building the Professor table");
state = Schedule.con.createStatement();
state.executeUpdate("CREATE TABLE Professor_Table(" +
"TUID INTEGER," +
"Professor_Name VARCHAR(60)," +
"PRIMARY KEY (TUID));");

System.out.println("Building the classroom table");
state = Schedule.con.createStatement();
state.executeUpdate("CREATE TABLE Classroom_Table(" +
"TUID INTEGER," +
"Classroom_Name VARCHAR(4)," +
"Capacity INTEGER," +
"PRIMARY KEY (TUID));");

System.out.println("Building the schedule table");
state = Schedule.con.createStatement();
state.executeUpdate("CREATE TABLE Schedule_Table(" +
"TUID INTEGER," +
"Course_TUID INTEGER," +
"Section INTEGER," +
"Classroom_TUID INTEGER," +
"Professor_TUID INTEGER," +
"Start_time TIME," +
"End_time TIME," +
"Days VARCHAR(4)," +
"PRIMARY KEY (TUID)," +
"FOREIGN KEY (Course_TUID) REFERENCES Course_Table(Course_TUID)," +
"FOREIGN KEY (Classroom_TUID) REFERENCES Classroom_Table(Classroom_TUID)," +
"FOREIGN KEY (Professor_TUID) REFERENCES Professor_Table(Professor_TUID));");

//Add courses
System.out.println("Populating Course Table");
prep = Schedule.con.prepareStatement("INSERT INTO Course_Table(Course_ID,Course_Title,Credit_Hours) VALUES(?,?,?);");
prep.setString(1, "CSC 105");
prep.setString(2, "Computers and Programming");
prep.setInt(3, 4);
prep.addBatch();
prep.setString(1, "CSC 107");
prep.setString(2, "Introduction to Code Preparation");
prep.setInt(3, 1);
prep.addBatch();
prep.setString(1, "CSC 116");
prep.setString(2, "Programming I");
prep.setInt(3, 4);
prep.addBatch();
prep.setString(1, "CSC 216");
prep.setString(2, "Programming II");
prep.setInt(3, 4);
prep.addBatch();
prep.setString(1, "CSC 227");
prep.setString(2, "Commenting and Naming Conventions");
prep.setInt(3, ...


Anonymous
Great study resource, helped me a lot.

Studypool
4.7
Indeed
4.5
Sitejabber
4.4

Related Tags