Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are on the Welcoming Committee at “Geeks –R- Us”, you are tasked with buildi

ID: 3786011 • Letter: Y

Question

You are on the Welcoming Committee at “Geeks –R- Us”, you are tasked with building a basic information data sheet on the new potential employees. Write a program that will display a (prototype of new layout) the first name, middle initial, last name, full name (store first name, middle name and last name into full name) age, salary and sex of new employee. Then displays that person’s name with the first name first, middle initial followed by a period, and last name then age, salary and sex on the monitor. Make sure the output is easy to read and understand.

Use good programming techniques.

Should do this homework twice, one using System.out.println("  ");


and one using JOptionPane.

If you do both each is worth 50 points.

also could you recomend a compiler that i can use to run it and use it?

Explanation / Answer

import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;

public class Registration extends JFrame {
   private Container con;
   JButton jb1, jb2, jb3;
   JLabel jl1, jl2, jl3, jl4, jl5, jl6, jl7;
   JTextField jt1, jt2, jt3, jt4, jt5, jt6;

   public Registration(){
       super("User Registartion");
       con = getContentPane();
       con.setLayout(new FlowLayout());
      
       jl1 = new JLabel("First Name");
       jl2 = new JLabel("Midle name");
       jl3 = new JLabel("Lat Name");
       jl4 = new JLabel("Age");
       jl5 = new JLabel("Sex");
       jl6 = new JLabel("Salary");
      
       jl7 = new JLabel();
      
       jt1 = new JTextField(20);
       jt2 = new JTextField(20);
       jt3 = new JTextField(20);
       jt4 = new JTextField(2);
       jt5 = new JTextField(1);
       jt6 = new JTextField(6);
      
       jb1 = new JButton("Save / Register");
       jb2 = new JButton("cancel");
       jb3 = new JButton("Reset");
      
       con.add(jl1); con.add(jt1);
       con.add(jl2); con.add(jt2);
       con.add(jl3); con.add(jt3);
       con.add(jl4); con.add(jt4);
       con.add(jl5); con.add(jt5);
       con.add(jl6); con.add(jt6);
      
       con.add(jb1); con.add(jb2);con.add(jb3);
       setVisible(true);
       setSize(400,200);
       class MyAction implements ActionListener{

           @Override
           public void actionPerformed(ActionEvent ae) {
               // TODO Auto-generated method stub
               if(ae.getSource()==jb1){
                   try{
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
               Connection conn = DriverManager.getConnection("jdbc:odbc:employee");
                  //make sure before executing the program you must create table in ms access and give data base name as employee
                  PreparedStatement pstm=conn.prepareStatement("insert into employee values(?,?,?,?,?,?)");
                        pstm.setString(1,jt1.getText());
                        pstm.setString(2,jt2.getText());
                        pstm.setString(3,jt3.getText());
                        pstm.setString(4,jt4.getText());
                        pstm.setString(5,jt5.getText());
                        pstm.setString(6,jt6.getText());
                      
                      
                        pstm.executeUpdate();
                      
                       jl7.setText("Details have been added to database");
                            pstm.close();
                         conn.close();
                       }catch(SQLException ex)
                       {
                         System.out.println("SQl error"+ex);
               }
              
           }
               if(ae.getSource()==jb2 || ae.getSource()==jb3){
                   jt1.setText("");
                   jt2.setText("");
                   jt3.setText("");
                   jt4.setText("");
                   jt5.setText("");
                   jt6.setText("");
                  
               }
                  
               }
          
       }
              
   }

   public static void main(String rags[]) {
       Registration r = new Registration();
       r.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote