JAVA: Create a school registration menu. This menu should display the name of th
ID: 664870 • Letter: J
Question
JAVA: Create a school registration menu. This menu should display the name of the school, a welcome message, and a way for students to log in. Include your name as part of the college name.
Students Log-in. Prompt the user for their name and student ID. Ensure that the ID is in the proper format: A five-digit number that begins with 9. If it is not valid, present an error message until it is valid.
Class List. After students log in, present a list of classes. Classes are located in a text file classList.txt that contains the following information separated by commas: class name, class number, professor, credit hours and seat left. Read the file and store contents into some type of list, array or queue. Display the class list and allow student to select one or enter the class number of the requested class for registration.
Class Availability. There is a limit of no more than five students per class. This is a very small and exclusive school. Notify the student if the selected class is full. Once a student registers for the class, update the number of available seats and write this information back to the file.
Calculate Registration Cost: The cost of classes is $500 per credit unit. There are addictional one time only fees each semester: Activity fee- $10, health fee-$15. Technology Fee-$20, and an institution fee of $100. Calculate the student's cost for classes
Confirm Registration and present cost. Present student with a bill. Make sure the bill is itemized, showing the student's name and id, listing classes the student has registered for with cost per class, and showing the additional semester fees. Display cost.
Include Comments in your source code. Have a block comment header at the beginning of your program with this info: Class Name, Class Number, Instructor, Date, and Your Name. include some meaningful Comments in your program at a minimum you'll need include a comment before your methods explaining what you're doing.
Test each feature to demonstrate your program works.
Explanation / Answer
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.rmi.*;
import java.util.Vector;
public class Applications extends JFrame implements ActionListener{
JLabel labelTitle;
JLabel lApp_Num;
JLabel lApp_Dt;
JLabel lProg_Code;
JLabel lSch_Code;
JLabel lApp_Fees;
JLabel lApp_Status;
JTextField tApp_Num;
JTextField tApp_Dt;
JTextField tProg_Code;
JTextField tSch_Code;
JTextField tApp_Fees;
JTextField tApp_Status;
JPanel pan1, pan2, pan3;
JButton submit, reset, view, update, delete, cancel;
String App_Num;
String App_Dt;
String Prog_Code;
String Sch_Code;
String App_Fees;
String App_Status;
String Emp_Type;
static Color c;
static String Ip;
public Applications(){
}
public Applications(String emp_Type, Color c, String ip){
Emp_Type=emp_Type;
Ip=ip;
this.c=c;
setTitle(Emp_Type+" (Application Interface) "+"Connected to: "+Ip);
setSize(500, 300);
pan1 = new JPanel();
pan2 = new JPanel();
pan3 = new JPanel();
pan1.setLayout(new FlowLayout(FlowLayout.CENTER));
pan2.setLayout(new GridLayout(6,2));
pan3.setLayout(new GridLayout(1,1));
pan1.setBackground(c);
pan2.setBackground(Color.white);
pan3.setBackground(Color.white);
Icon logo=new ImageIcon(getClass().getResource("flame.gif"));
labelTitle=new JLabel();
labelTitle.setIcon(logo);
labelTitle.setText("UNIVERSITY OF TAYSIDE");
labelTitle.setHorizontalTextPosition(SwingConstants.CENTER);
labelTitle.setVerticalTextPosition(SwingConstants.BOTTOM);
labelTitle.setFont(new Font("Arial",Font.BOLD,20));
labelTitle.setToolTipText("Welcome to University of Tayside");
pan1.add(labelTitle);
lApp_Num = new JLabel("Application number (i.e App02)");
pan2.add(lApp_Num);
tApp_Num = new JTextField(15);
pan2.add(tApp_Num);
lApp_Dt=new JLabel("Apllication Date (i.e yyyy-mm-dd)");
pan2.add(lApp_Dt);
tApp_Dt = new JTextField(15);
tApp_Dt.setToolTipText("YYYY-MM-DD");
pan2.add(tApp_Dt);
lProg_Code = new JLabel("Program Code");
lProg_Code.setToolTipText("Must match a program code in Program Schdules table");
pan2.add(lProg_Code);
tProg_Code = new JTextField(15);
tProg_Code.setToolTipText("Must match a program code in Program Schdules table");
pan2.add(tProg_Code);
lSch_Code = new JLabel("School Code");
lSch_Code.setToolTipText("Must match a School code in Graduate School table");
pan2.add(lSch_Code);
tSch_Code = new JTextField(15);
tSch_Code.setToolTipText("Must match a School code in Graduate School table");
pan2.add(tSch_Code);
lApp_Fees = new JLabel("Application Fee (i.e 3500)");
pan2.add(lApp_Fees);
tApp_Fees = new JTextField(15);
pan2.add(tApp_Fees);
lApp_Status = new JLabel("Aplication Status");
lApp_Status.setToolTipText("Rejected, Selected for admission, Admitted, Canceled");
pan2.add(lApp_Status);
tApp_Status = new JTextField(15);
tApp_Status.setToolTipText("Rejected, Selected for admission, Admitted, Canceled");
pan2.add(tApp_Status);
submit = new JButton("Submit");
submit.addActionListener(this);
submit.setToolTipText("Submit the form details to the server");
pan3.add(submit);
reset = new JButton("Reset");
reset.addActionListener(this);
reset.setToolTipText("Clear the the text field area");
pan3.add(reset);
view = new JButton("View");
view.addActionListener(this);
view.setToolTipText("View details");
pan3.add(view);
update = new JButton("Update");
update.addActionListener(this);
update.setToolTipText("Update details");
pan3.add(update);
delete = new JButton("Delete");
delete.addActionListener(this);
delete.setToolTipText("Delete details");
pan3.add(delete);
cancel = new JButton("Exit");
cancel.addActionListener(this);
cancel.setToolTipText("Exit the form");
pan3.add(cancel);
getContentPane().add(pan1, BorderLayout.NORTH);
getContentPane().add(pan2, BorderLayout.CENTER);
getContentPane().add(pan3, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
}
private void display()
{
Vector vec = null;
String App_Num=tApp_Num.getText();
String App_Dt="";
String Prog_Code="";
String Sch_Code="";
String App_Fees="";
String App_Status="";
try
{
/* Find the remote object at specified URL */
vec = RemoteObject.getRemoteObject(Ip, "AppView").viewAppForm(App_Num);
if((vec!=null) && (vec.size()>0))
{
App_Dt=(String) vec.elementAt(0);
Prog_Code=(String) vec.elementAt(1);
Sch_Code=(String) vec.elementAt(2);
App_Fees=(String) vec.elementAt(3);
App_Status=(String) vec.elementAt(4);
tApp_Dt.setText(App_Dt);
tApp_Dt.setEditable(true);
tProg_Code.setText(Prog_Code);
tProg_Code.setEditable(true);
tSch_Code.setText(Sch_Code);
tSch_Code.setEditable(true);
tApp_Fees.setText(App_Fees);
tApp_Fees.setEditable(true);
tApp_Status.setText(App_Status);
tApp_Status.setEditable(true);
}
/*else{
appDialog = new AppDialog(this, "No Records Found");
appDialog.setVisible(true);
appDialog.setBackground(c);}*/
}
catch(Exception e)
{
System.out.println("In Display "+e);
}
}
private void delete(){
AppDialog appDialog;
try
{
App_Num=tApp_Num.getText();
/* Find the remote object at specified URL */
String str = RemoteObject.getRemoteObject(Ip, "AppDelete").deleteAppForm(App_Num);
if(str.trim().equals("Records Inserted")){
appDialog = new AppDialog(this, "Records Deleted");
appDialog.setVisible(true);
appDialog.setBackground(c);
tApp_Num.setText("");
tApp_Dt.setText("");
tProg_Code.setText("");
tSch_Code.setText("");
tApp_Fees.setText("");
tApp_Status.setText("");
}
else{
appDialog = new AppDialog(this, "Records Not Deleted");
appDialog.setVisible(true);
appDialog.setBackground(c);}
}
catch(Exception e)
{
System.out.println(e);
}
}
private void update(){
AppDialog appDialog;
try
{
App_Num=tApp_Num.getText();
App_Dt=tApp_Dt.getText();
Prog_Code=tProg_Code.getText();
Sch_Code=tSch_Code.getText();
App_Fees=tApp_Fees.getText();
App_Status=tApp_Status.getText();
/* Find the remote object at specified URL */
String str = RemoteObject.getRemoteObject(Ip, "AppUpdate").updateAppForm(App_Num, App_Dt, Prog_Code, Sch_Code, App_Fees, App_Status);
if(str.trim().equals("Records Inserted")){
appDialog = new AppDialog(this, "Records Updated");
appDialog.setVisible(true);
appDialog.setBackground(c);
tApp_Num.setText("");
tApp_Dt.setText("");
tProg_Code.setText("");
tSch_Code.setText("");
tApp_Fees.setText("");
tApp_Status.setText("");
}
else{
appDialog = new AppDialog(this, "Records Not Updated");
appDialog.setVisible(true);
appDialog.setBackground(c);}
}
catch(Exception e)
{
System.out.println(e);
}
}
public void actionPerformed(ActionEvent ae)
{
AppDialog appDialog;
if(ae.getSource() == submit)
{
try
{
App_Num=tApp_Num.getText();
App_Dt=tApp_Dt.getText();
Prog_Code=tProg_Code.getText();
Sch_Code=tSch_Code.getText();
App_Fees=tApp_Fees.getText();
App_Status=tApp_Status.getText();
/* Find the remote object at specified URL */
String str = RemoteObject.getRemoteObject(Ip, "AppInsert").insertAppForm(App_Num, App_Dt, Prog_Code, Sch_Code, App_Fees, App_Status);
if(str.trim().equals("Records Inserted")){
appDialog = new AppDialog(this, "Records Inserted");
appDialog.setVisible(true);
appDialog.setBackground(c);
tApp_Num.setText("");
tApp_Dt.setText("");
tProg_Code.setText("");
tSch_Code.setText("");
tApp_Fees.setText("");
tApp_Status.setText("");
}
else{
appDialog = new AppDialog(this, "Records Not Inserted");
appDialog.setVisible(true);
appDialog.setBackground(c);}
}
catch(Exception e)
{
System.out.println(e);
}
}
else if(ae.getSource() == reset)
{
tApp_Num.setText("");
tApp_Dt.setText("");
tProg_Code.setText("");
tSch_Code.setText("");
tApp_Fees.setText("");
tApp_Status.setText("");
}
else if(ae.getSource() == view)
{
display();
}
else if(ae.getSource() == update)
{
update();
}
else if(ae.getSource() == delete)
{
delete();
}
else if(ae.getSource() == cancel)
{
this.setVisible(false);
}
}
public static void main(String arg[])
{
Applications form = new Applications();
form.setVisible(true);
form.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
form.setResizable(false);
form.setDefaultLookAndFeelDecorated(true);
}
}
class AppDialog extends Dialog implements ActionListener
{
AppDialog(JFrame parent, String title)
{
super(parent, "Status", false);
setLayout(new FlowLayout());
setSize(120, 100);
parent.setDefaultLookAndFeelDecorated(true);
add(new JLabel(title));
JButton button_OK = new JButton("OK");
add(button_OK);
button_OK.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
dispose();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.