This tutorial will teach you to make a small shop Grocery Shop Inventory system. The following system will use to manage the Grocery Shop.
paste the code inside the ok button
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | double sum = 0; double price; double qty; double cal = 0; if(chk1.isSelected()) { String suger = chk1.getText(); String mes= txtsum.getSelectedItem().toString(); price = 140.0; qty = Integer.parseInt(txtsqty.getText().toString()); if(mes.equals("KG")) { cal = (qty * price) ; model = (DefaultTableModel)jTable1.getModel(); model.addRow(new Object[] { suger, price, qty, cal }); } else { cal = (qty/1000 * price) ; model = (DefaultTableModel)jTable1.getModel(); model.addRow(new Object[] { suger, price, qty, cal }); } if(chk2.isSelected()) { String tea = chk2.getText(); String mes1= txtstut.getSelectedItem().toString(); price = 200.0; qty = Integer.parseInt(txttqty.getText().toString()); if(mes1.equals("KG")) { cal = (qty * price) ; model = (DefaultTableModel)jTable1.getModel(); model.addRow(new Object[] { tea, price, qty, cal }); } else { cal = (qty/1000 * price) ; model = (DefaultTableModel)jTable1.getModel(); model.addRow(new Object[] { tea, price, qty, cal }); } } if(chk3.isSelected()) { String flour = chk3.getText(); String mes2= txtflum.getSelectedItem().toString(); price = 250.0; qty = Integer.parseInt(txtfqty.getText().toString()); if(mes2.equals("KG")) { cal = (qty * price) ; model = (DefaultTableModel)jTable1.getModel(); model.addRow(new Object[] { flour, price, qty, cal }); } else { cal = (qty/1000 * price) ; txtbill.setText(String.valueOf(cal)); model = (DefaultTableModel)jTable1.getModel(); model.addRow(new Object[] { flour, price, qty, cal }); } } if(chk4.isSelected()) { String rice = chk4.getText(); String mes3= txtricm.getSelectedItem().toString(); price = 250.0; qty = Integer.parseInt(txtrqty.getText().toString()); if(mes3.equals("KG")) { cal = (qty * price) ; model = (DefaultTableModel)jTable1.getModel(); model.addRow(new Object[] { rice, price, qty, cal }); } else { cal = (qty/1000 * price) ; model = (DefaultTableModel)jTable1.getModel(); model.addRow(new Object[] { rice, price, qty, cal }); } } if(chk5.isSelected()) { String dhall = chk5.getText(); String mes4= txtdham.getSelectedItem().toString(); price = 350.0; qty = Integer.parseInt(txtdqty.getText().toString()); if(mes4.equals("KG")) { cal = (qty * price) ; model = (DefaultTableModel)jTable1.getModel(); model.addRow(new Object[] { dhall, price, qty, cal }); } else { cal = (qty/1000 * price) ; model = (DefaultTableModel)jTable1.getModel(); model.addRow(new Object[] { dhall, price, qty, cal }); } } for(double i=0; i <jTable1.getRowCount(); i++) { sum = sum + Double.parseDouble(jTable1.getValueAt((int) i, 3).toString()); } txtbill.setText(Double.toString(sum)); } |