You will build part of a college\'s course registration system (similar to WebRe
ID: 3697261 • Letter: Y
Question
You will build part of a college's course registration system (similar to WebReg, though considerably less complex). The system will keep track of a catalog of courses that students can take. It will allow the user (a student) to view and search the course catalog, and to add (register for) and drop (withdraw from) courses.
The following restrictions apply:
All courses meet only once per week, for one class period.
Days will be denoted by the following letters: M - Monday, T - Tuesday, W - Wednesday, H - Thursday, F - Friday, S - Saturday. There are no Sunday courses.
Class periods (time slots) are numbered from 1 to 9. A student cannot register for a course that is not in the catalog.
There is a limit on the number of courses a student may take in one semester. There is NO explicit limit on the number of credits a student may carry in one semester. A student cannot register for two courses that meet on the same day and time.
Sorting Courses and Analysis (Phase 4) Implement the following methods in WebReg.java.
DO NOT modify your Period, Course, and Student objects.
If needed, you may add helper methods and fields in WebReg.java.
public static Course[] commonCourses(Student one, Student two)
given two students, return a list of all the courses both of the students are taking together in a new array (in any order). the returned array should be just large enough to hold the results, and no larger; it should not contain any empty (null) entries. if there are no courses in common, return null.
public static void sortByNumber(Course[] catalog)
sort the catalog into ascending order by department and course number (i.e., courses should be ordered by department number, and courses in the same department should be ordered by individual course number). you may use any sorting algorithm that you wish.
public static void sortByTime(Course[] catalog)
sort the catalog into chronological order by meeting day and time (i.e., courses should be ordered by the day of week on which they meet, and courses that meet on the same day should be ordered by the class period at which they meet). you may use any sorting algorithm that you wish. Submit WebReg.java
Use method signatures given not new parameters. The other files (Period, Student, Course) were answered in a chegg question so you can probably see it.
Explanation / Answer
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class student extends Frame implements ActionListener
{String msg;
Button b1=new Button("save");
Label l11=new Label("Student details",Label.CENTER);
Label l1=new Label("Name:",Label.LEFT);
Label l2=new Label("age:",Label.LEFT);
Label l3=new Label("Sex(M/F):",Label.LEFT);
Label l4=new Label("Address:",Label.LEFT);
Label l5=new Label("Course:",Label.LEFT);
Label l6=new Label("Semester:",Label.LEFT);
Label l7=new Label("",Label.RIGHT);
TextField t1=new TextField();
Choice c1=new Choice();
CheckboxGroup cbg=new CheckboxGroup();
Checkbox ck1=new Checkbox("Male",false,cbg);
Checkbox ck2=new Checkbox("Female",false,cbg);
TextArea t2=new TextArea("",180,90,TextArea.SCROLLBARS_VERTICAL_ONLY);
Choice course=new Choice();
Choice sem=new Choice();
Choice age=new Choice();
public student()
{addWindowListener(new myWindowAdapter());
setBackground(Color.cyan);
setForeground(Color.black);
setLayout(null);
add(l11);
add(l1);
add(l2);
add(l3);
add(l4);
add(l5);
add(l6);
add(l7);
add(t1);
add(t2);
add(ck1);
add(ck2);
add(course);
add(sem);
add(age);
add(b1);
b1.addActionListener(this);
add(b1);
course.add("BSc c.s");
course.add("BSc maths");
course.add("BSc physics");
course.add("BA English");
course.add("BCOM");
sem.add("1");
sem.add("2");
sem.add("3");
sem.add("4");
sem.add("5");
sem.add("6");
age.add("17");
age.add("18");
age.add("19");
age.add("20");
age.add("21");
l1.setBounds(25,65,90,20);
l2.setBounds(25,90,90,20);
l3.setBounds(25,120,90,20);
l4.setBounds(25,185,90,20);
l5.setBounds(25,260,90,20);
l6.setBounds(25,290,90,20);
l7.setBounds(25,260,90,20);
l11.setBounds(10,40,280,20);
t1.setBounds(120,65,170,20);
t2.setBounds(120,185,170,60);
ck1.setBounds(120,120,50,20);
ck2.setBounds(170,120,60,20);
course.setBounds(120,260,100,20);
sem.setBounds(120,290,50,20);
age.setBounds(120,90,50,20);
b1.setBounds(120,350,50,30);
}
public void paint(Graphics g)
{g.drawString(msg,200,450);}
public void actionPerformed(ActionEvent ae)
{if(ae.getActionCommand().equals("save"))
{msg="Student details saved!";
setForeground(Color.red); }
}
public static void main(String g[])
{student stu=new student();
stu.setSize(new Dimension(500,500));
stu.setTitle("student registration");
stu.setVisible(true);
}
}
class myWindowAdapter extends WindowAdapter
{public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.