System Analysis and Design Lab 7: Question 1: Part A
System Analysis and Design Lab 7: Question 1: Part A
Question 1: Part A In question1 in the last sheet: Put the form contents (Number1and Number2 and Result labels. And the 3 text fields) in a Panel called Number Addition and put in it the Add button and another button called Clear to clear the content of text fields..Outside the panel put a button called Exit to close the whole form, as shown in the next form
Use the following libraries: import java.sql.*; import javax.swing.*; Question 1: Part B Modify the above program to include 4 panels for the Addition, Subtraction, Division and Multiplication of the two numbers
Question 2: Part A Create 2 tables Patient and Doctor where each patient treated with one doctor and the doctor treats many patients. Add the appropriate attributes in each table. Insert 2 records in each table.
Question 2: Part B Create a java application that asks the user for the doctors ID, Name, Age, and Gender (where the Gender attribute is presented by combo box) and then a new row is inserted in the Doctor table. Note that you have to make a panel called Doctor Data as shown:
Reminder: The following code will be used for the connection between the application side and the database created: Connection con = null; Statement st= null; ResultSet rs= null; try { con = DriverManager.getConnection("jdbc:derby://localhost:1527/Databasename", "username", "password"); st= con.createStatement(); rs= st.executeQuery("your Select statement is placed here ); while (rs.next()) { //code for retrieving the result } con.close(); } catch (Exception e) { System.err.println("Exception: "+e.getMessage()); }
Note1: Add check constraint to the gender to make sure that it takes the values Male or Female
Note2: to insert the gender selected from the combo box, you have to cast from object (selected item in the combo box) to string (specified data type of gender attribute in the Doctor table).
Question 2: Part C Modify the program in part B to allow user to retrieve the doctors data by specifying his ID as shown :
Note3: to fill in the combo box with table data you have to initiate an object from the DefaultComboBoxModel class.