I am almost at the end of my project and have some problems solving it. I m a chef who wants his own application what is relevant for his own bussines
My form is called Recipes and have Qty unitprice, % used.
So lets say, you have 1kg apples for 5 euro. At the end of cleaning you just have 800 grams of apples. So i have paid 20 percent more.
example
- Item is always 100%,
- Qty 5,
- Unitprice 5,
- Used% 100% total = 25
Qty 5, Unitprice 5, Used% 70%, Total= 32.5 ( must increase with 30 percent)
At the end I would have to calculate the Foodcost.
So "Total Cost / Selling price * 100"
I m stuck with this code. Please can someone help me further with my project. I just met java 1 week ago. So i don t have time to learn it properly. working 12h per day.
This is in the header in eclipse
public class Recipe extends javax.swing.JFrame {
double Qty;
double UnitPrice;
double Used;
double total;
double subTotal;
private static Connection connection = null;
private JPanel contentPane;
Connection conn=null;
JButton btnNewButtonAdd = new JButton("Add");
// btnNewButtonAdd.setIcon(new // ??
btnNewButtonAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int i=100;
Qty=Double.parseDouble(textFieldQty.getText());
UnitPrice=Double.parseDouble(txtUnitPrice.getText());
Used=Double.parseDouble(textFieldUsed.getText());
//Used=subTotal/100;
subTotal=Qty*UnitPrice;
//total=subTotal*Used;
//Used=subTotal/100;
total=subTotal*(Used/100);//(100+Used);
String TotalRow= String.format("%.2f", total);
txtTotal.setText(TotalRow);
DefaultTableModel model=(DefaultTableModel) table.getModel();
model.addRow(new Object[]{textFieldQty.getText(), BoxCategory.getSelectedItem(),
BoxDescription.getSelectedItem(), textFieldItemID.getText(),
txtUnitPrice.getText(), BoxUnit.getSelectedItem(), textFieldUsed.getText(),
txtTotal.getText()});
}
}
As shown here, here and here, you can calculate derived values in your implementation of
getValueAt()
. In the example below,COLUMN_PERCENT
is the ratio of each row's salary to thesum()
of salaries in the table.The percent column also gets an instance of
PercentFormatter
to format the derived value as a percentage.