Write an application containing three parallel arrays that hold 10 elements each. The first array
hold four-digit student ID numbers, the second array holds first names, and the third array holds
the students’ grade point averages. Use dialog boxes to accept a student ID number and display
the student’s first name and grade point average. If a match is not found, display an error
message that includes the invalid ID number and allow the user to search for a new ID number.
Solution
package javaapplication;
public class BoxJFrame extends javax.swing.JFrame {
/**
* Creates new form BoxJFrame
*/
private int[] studentsID = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
private String[] studentsName ={\"Alan\", \"Cris\", \"Joe\", \"Suzzy\", \"Stan\", \"Eminem\",
\"Josh\", \"Ann\", \"Katy\", \"Ralph\"};
private double[] studentsGP = {2.8, 4.1, 3.5, 4.0, 3.8, 3.75, 3.0, 4.2, 3.9, 3.6};
public BoxJFrame() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings(\"unchecked\")
//
//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jLabel1 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane2 = new javax.swing.JTextPane();
jButton1 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jScrollPane1.setViewportView(jTextPane1);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText(\"Input student ID\");
jScrollPane2.setViewportView(jTextPane2);
jButton1.setText(\"Search\");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
}
);
jLabel2.setText(\"Result\");
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane3.setViewportView(jTextArea1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(25, 25, 25)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 135,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 179,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(42, 42, 42)
.addComponent(jButton1))
.addGroup(layout.createSequentialGroup()
.addGap(226, 226, 226)
.addComponent(jLabel2)))
.addContainerGap(43, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.T.
Write an application containing three parallel arrays that hold 10 e.pdf
1. Write an application containing three parallel arrays that hold 10 elements each. The first array
hold four-digit student ID numbers, the second array holds first names, and the third array holds
the students’ grade point averages. Use dialog boxes to accept a student ID number and display
the student’s first name and grade point average. If a match is not found, display an error
message that includes the invalid ID number and allow the user to search for a new ID number.
Solution
package javaapplication;
public class BoxJFrame extends javax.swing.JFrame {
/**
* Creates new form BoxJFrame
*/
private int[] studentsID = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
private String[] studentsName ={"Alan", "Cris", "Joe", "Suzzy", "Stan", "Eminem",
"Josh", "Ann", "Katy", "Ralph"};
private double[] studentsGP = {2.8, 4.1, 3.5, 4.0, 3.8, 3.75, 3.0, 4.2, 3.9, 3.6};
public BoxJFrame() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
//
//GEN-BEGIN:initComponents
private void initComponents() {
2. jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jLabel1 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane2 = new javax.swing.JTextPane();
jButton1 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jScrollPane1.setViewportView(jTextPane1);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Input student ID");
jScrollPane2.setViewportView(jTextPane2);
jButton1.setText("Search");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
}
);
jLabel2.setText("Result");
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane3.setViewportView(jTextArea1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(