Java codding Please Problem WinstonSalem State Universitys O
Java codding Please
Problem: Winston-Salem State University’s Office of Budget Management needs a java program to assist in determining how much money can be saved by cancelling classes in the English, Social Science, and Mathematics Departments next semester. It costs the University $3000 to implement each class. The criteria used for cancelling classes are as follows:
. Classes with less than 10 students
. Classes that meet after 6 pm (1800) and taught by Part-time instructors
They have contracted you to prepare a report based on the information in the database(textfile). The database (budget.txt) contains the following information:
- Course ID (i.e. ENG2301-01)
- Course Title
- Time Course Start (in military time)
- Enrollment
- Type Instructor (F- Fulltime, P-Part-time)
Sample Data:
Eng2310-01/ Intro to Speech/1700/28/F
Secondly, they need you to prepare a report containing the following information:
1- Read and display the contents of the file.
2- Display the course information for all cancelled classes.
3- Display the reason(s) why the course was cancelled.
4- Display a list of savings by department.
5- Display the total amount that the university will save by cancelling the classes.
6- Determine and display the department that will save the most from cancelling classes
Your program should produce output similar to the following:
*Contents of the file
Your program should produce output similar to the following:
*Contents of the file
Course ID Course Title Start Time Enrollment Type Instructor
MAT1311-01 College Math I 1700 28 P
MAT1311-02 College Math I 1800 5 F
MAT1311-03 College Math I 0800 28 P
MAT1311-04 College Math I 0900 28 F
MAT1311-05 College Math I 1300 4 F
ENG 1301-01 Fresh Comp 1800 30 P
ENG 1301-02 Fresh Comp 1800 5 P
ENG 1301-03 Fresh Comp 0800 28 F
ENG 1301-04 Fresh Comp 1100 25 F
ENG 1301-05 Fresh Comp 1300 28 F
ENG 1301-06 Fresh Comp 1900 28 P
ENG 1301-07 Fresh Comp 0800 15 F
ENG 1301-08 Fresh Comp 0800 28 F
ENG 1301-09 Fresh Comp 1000 10 F
ENG1301-10 Fresh Comp 1300 28 F
SOC2310-01 Intro to Speech 100 10 F
SOC2310-02 Intro to Speech 1700 30 P
SOC2310-03 Intro to Speech 1900 18 P
SOC2310-04 Intro to Speech 1200 8 F
SOC2310-05 Intro to Speech 1400 9 F
SOC2310-06 Intro to Speech 1800 18 P
SOC2310-07 Intro to Speech 1300 28 F
SOC2310-08 Intro to Speech 1800 5 P
*Course Information for cancelled classes
MAT1311-02 College Math I 1800 5 F
MAT1311-05 College Math I 1300 4 F
ENG 1301-02 Fresh Comp 1800 5 P
ENG 1301-06 Fresh Comp 1900 28 P
SOC2310-03 Intro to Speech 1900 18 P
SOC2310-04 Intro to Speech 1200 8 F
SOC2310-05 Intro to Speech 1400 9 F
SOC2310-08 Intro to Speech 1800 5 P
*Reasons why the course was cancelled
Course Reason(s)
MAT1311-02 Low Enrollment
MAT1311-05 Low Enrollment
ENG 1301-02 Low Enrollment
ENG 1301-06 Time and Instructor
SOC2310-03 Time and Instructor
SOC2310-04 Low Enrollment
SOC2310-05 Low Enrollment
SOC2310-08 Low Enrollment
*Savings by department
Mathematics $ 6000
English $ 6000
Social Science $12000
*Total Savings for the University - $24000
*The Social Science Department will save the most money.
Here is the text File
Solution
PROGRAM CODE:
BudgetManagement.java
package sample;
/*
* This class will hold all the data from the text file.
*/
public class BudgetManagement {
String courseID;
String courseTitle;
int startTime;
int enrollment;
String typeIns;
String cancellationReason;
boolean isCancelled;
//setters and getters
public String getCourseID() {
return courseID;
}
public void setCourseID(String courseID) {
this.courseID = courseID;
}
public String getCourseTitle() {
return courseTitle;
}
public void setCourseTitle(String courseTitle) {
this.courseTitle = courseTitle;
}
public int getStartTime() {
return startTime;
}
public void setStartTime(int startTime) {
this.startTime = startTime;
}
public int getEnrollment() {
return enrollment;
}
public void setEnrollment(int enrollment) {
this.enrollment = enrollment;
}
public String getTypeIns() {
return typeIns;
}
public void setTypeIns(String typeIns) {
this.typeIns = typeIns;
}
public String getCancellationReason() {
return cancellationReason;
}
public void setCancellationReason(String cancellationReason) {
this.cancellationReason = cancellationReason;
}
public boolean isCancelled() {
return isCancelled;
}
public void setCancelled(boolean isCancelled) {
this.isCancelled = isCancelled;
}
public void display()
{
System.out.println(getCourseID() + \"\\t\" + getCourseTitle() + \"\\t\\t\" + getStartTime() + \"\\t\\t\" + getEnrollment() + \"\\t\\t\" + getTypeIns());
}
}
MainClass.java
package sample;
import java.io.BufferedReader;
 import java.io.FileReader;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.regex.Pattern;
//This is the main class which will read the file and do the manipulation
 public class MainClass {
    static ArrayList<BudgetManagement> list = new ArrayList<>();
   
    public static void main(String args[])
    {
        // using buffered reader to read from the database.txt file
        try(BufferedReader br = new BufferedReader(new FileReader(\"database.txt\"))) {
        for(String line; (line = br.readLine()) != null; ) {
        //Storing each line of the file into the BudegetManagement class using setter methods
            BudgetManagement bm = new BudgetManagement();
        String[] tokens = line.split(Pattern.quote(\"/\"));
        bm.setCourseID(tokens[0]);
        bm.setCourseTitle(tokens[1]);
        bm.setStartTime(Integer.valueOf(tokens[2]));
        bm.setEnrollment(Integer.valueOf(tokens[3]));
        bm.setTypeIns(tokens[4]);
        bm.setCancelled(false);
        bm.setCancellationReason(\"\");
        list.add(bm);
        }
        br.close();
        // line is not visible here.
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
       
        //Displaying the contents of the file on the screen
        System.out.println(\"*Contents of the file\");
        System.out.println(\"Course ID\\tCourse Title\\t\\tStart Time\\tEnrollment\\tType Instructor\ \");
        for(int i=0; i<list.size(); i++)
        {
            list.get(i).display();
        }
        System.out.println(\"\");
        //removing the classes which do not satisfy the criteria
        for(int i=0; i<list.size(); i++)
        {
            if((list.get(i).getEnrollment() <10)) //criteria check for enrollemnt
            {
                list.get(i).setCancelled(true);
                list.get(i).setCancellationReason(\"Low Enrollment\");
            }
            //criteria check for type of instructor and start time
            else if((list.get(i).getTypeIns().equals(\"P\")) && (list.get(i).getStartTime()>1800))
            {
                list.get(i).setCancelled(true);
                list.get(i).setCancellationReason(\"Time and Instructor\");
            }
        }
       
        //Displaying the courses that are cancelled
        System.out.println(\"*Course Information for cancelled classes\ \");
        for(int i=0; i<list.size(); i++)
        {
            if(list.get(i).isCancelled)
            list.get(i).display();
        }
        System.out.println(\"\");
       
        //displayed the courses that are cancelled with reason
        System.out.println(\"*Reasons why the course was cancelled\ \");
        System.out.println(\"Course\\t\\tReason(s)\");
        for(int i=0; i<list.size(); i++)
        {
            if(list.get(i).isCancelled)
            {
                System.out.println(list.get(i).getCourseID() + \"\\t\" + list.get(i).getCancellationReason());
            }
           
        }
        System.out.println(\"\");
       
        //calculating the savings
        int math = 0, eng = 0, soc = 0;
        System.out.println(\"*Savings by department\");
        for(int i=0; i<list.size(); i++)
        {
            if(list.get(i).isCancelled)
            {
                if(list.get(i).getCourseID().contains(\"Eng\"))
                    eng++;
                else if(list.get(i).getCourseID().contains(\"MAT\"))
                    math++;
                else if(list.get(i).getCourseID().contains(\"SOC\"))
                    soc++;
            }
           
        }
        // printing the total amount saved for each subject
        System.out.println(\"Mathematics\\t$\"+math*3000);
        System.out.println(\"English\\t\\t$\"+eng*3000);
        System.out.println(\"Social Science\\t$\"+soc*3000);
        System.out.println(\"\");
       
        //total savings for the university
        System.out.println(\"*Total Savings for the University - $\" +( math+eng+soc)*3000 + \"\ \");
        //checking which subject has the most savings
        if(math > eng)
        {
            if(math>soc)
                System.out.println(\"*The Mathematics Department will save the most money.\");
            else
                System.out.println(\"*The Social Science Department will save the most money.\");
        }
        else
        {
            if(eng>soc)
                System.out.println(\"*The English Department will save the most money.\");
            else
                System.out.println(\"*The Social Science Department will save the most money.\");
        }
        System.out.println();
    }
 }
OUTPUT:
*Contents of the file
Course ID Course Title Start Time Enrollment Type Instructor
MAT131-101 College Math I 1700 28 P
MAT1311-02 College Math I 1800 5 F
MAT1311-03 College Math I 800 28 P
MAT1311-04 College Math I 900 28 F
MAT1311-05 College Math I 1300 4 F
Eng1301-01 Fresh Comp 1800 30 P
Eng1301-02 Fresh Comp 1800 5 P
Eng1301-03 Fresh Comp 800 28 F
Eng1301-04 Fresh Comp 1100 25 F
Eng1301-05 Fresh Comp 1300 28 F
Eng1301-06 Fresh Comp 1900 28 P
Eng1301-07 Fresh Comp 800 15 F
Eng1301-08 Fresh Comp 800 28 F
Eng1301-09 Fresh Comp 1000 10 F
Eng1301-10 Fresh Comp 1300 28 F
Eng2310-01 Intro to Speech 1100 10 F
SOC2310-02 Intro to Speech 1700 30 P
SOC2310-03 Intro to Speech 1900 18 P
SOC2310-04 Intro to Speech 1200 8 F
SOC2310-05 Intro to Speech 1400 9 F
SOC2310-06 Intro to Speech 1800 18 P
SOC2310-07 Intro to Speech 1300 28 F
SOC2310-08 Intro to Speech 1800 5 P
*Course Information for cancelled classes
MAT1311-02 College Math I 1800 5 F
MAT1311-05 College Math I 1300 4 F
Eng1301-02 Fresh Comp 1800 5 P
Eng1301-06 Fresh Comp 1900 28 P
SOC2310-03 Intro to Speech 1900 18 P
SOC2310-04 Intro to Speech 1200 8 F
SOC2310-05 Intro to Speech 1400 9 F
SOC2310-08 Intro to Speech 1800 5 P
*Reasons why the course was cancelled
Course Reason(s)
MAT1311-02 Low Enrollment
MAT1311-05 Low Enrollment
Eng1301-02 Low Enrollment
Eng1301-06 Time and Instructor
SOC2310-03 Time and Instructor
SOC2310-04 Low Enrollment
SOC2310-05 Low Enrollment
SOC2310-08 Low Enrollment
*Savings by department
Mathematics $6000
English $6000
Social Science $12000
*Total Savings for the University - $24000
*The Social Science Department will save the most money.








