Hey guys I am making a java application to book installation. I am trying to set up an If else statement to make the InstallType column print out either "Standard" or "Custom"
The way it needs to do this is: if the numOutlets variable is greater than 4 OR is numZones is greater than 2 then is should print out Custom.
If the number of either numOutlets is lower or equal to 4 or the number in numZones is equal to or less than 2 it should print out "Standard".
I am trying to make it do this on the enterButton:
public void enterButtonClicked(){
Installation installation = new Installation();
installation.setCustomerName(nameInput.getText());
installation.setHouseNumber(Double.parseDouble(houseInput.getText()));
installation.setStreetName(streetInput.getText());
installation.setTown(townInput.getText());
installation.setNumOutlets(Integer.parseInt(outletInput.getText()));
installation.setNumZones(Integer.parseInt(zoneInput.getText()));
installationTable.getItems().add(installation);
double numOutlets = Double.parseDouble(outletInput.getText());
double numZones = Double.parseDouble(zoneInput.getText());
if (numOutlets>=2 || numZones>=5)
installationType = "Custom";
else
installationType = "Standard";
installType.setText(InstallationType + "");
nameInput.clear();
houseInput.clear();
streetInput.clear();
townInput.clear();
outletInput.clear();
zoneInput.clear();
}
This is my TableView
public void start(Stage primaryStage) throws Exception {
window = primaryStage;
window.setTitle("CQ Air-Conditioning");
//installationID
TableColumn<Installation, Integer> installationID = new TableColumn<>("Installation ID");
installationID.setMinWidth(100);
installationID.setCellValueFactory(new PropertyValueFactory<>("installationNumber"));
//CustomerName
TableColumn<Installation, String> nameColumn = new TableColumn<>("Name");
nameColumn.setMinWidth(200);
nameColumn.setCellValueFactory(new PropertyValueFactory<>("customerName"));
//House Number
TableColumn<Installation, Double> houseNo = new TableColumn<>("House Number");
houseNo.setMinWidth(100);
houseNo.setCellValueFactory(new PropertyValueFactory<>("houseNumber"));
//Street Name
TableColumn<Installation, String> street = new TableColumn<>("Street Name");
street.setMinWidth(200);
street.setCellValueFactory(new PropertyValueFactory<>("streetName"));
//Town Name
TableColumn<Installation, String> Town = new TableColumn<>("Town Name");
Town.setMinWidth(200);
Town.setCellValueFactory(new PropertyValueFactory<>("town"));
//number outlets
TableColumn<Installation, Double> numberOutlets = new TableColumn<>("Outlets");
numberOutlets.setMinWidth(50);
numberOutlets.setCellValueFactory(new PropertyValueFactory<>("numOutlets"));
//number Zones
TableColumn<Installation, Double> numberZones = new TableColumn<>("Zones");
numberZones.setMinWidth(50);
numberZones.setCellValueFactory(new PropertyValueFactory<>("numZones"));
//Installation Type
TableColumn<Installation, String> installType = new TableColumn<>("Type of Installation");
installType.setMinWidth(200);
installType.setCellValueFactory(new PropertyValueFactory<>("installationType"));
//total cost
TableColumn<Installation, Double> cost = new TableColumn<>("Total Cost");
cost.setMinWidth(150);
cost.setCellValueFactory(new PropertyValueFactory<>("totalCost"));
//nameInput
nameInput = new TextField();
nameInput.setPromptText("Enter Name");
nameInput.setMinWidth(100);
//houseInput
houseInput = new TextField();
houseInput.setPromptText("enter house number");
//streetInput
streetInput = new TextField();
streetInput.setPromptText("enter street Name");
//town input
townInput = new TextField();
townInput.setPromptText("enter town");
//outlets input
outletInput = new TextField();
outletInput.setPromptText("enter number of outlets");
//zones input
zoneInput = new TextField();
zoneInput.setPromptText("enter number of zones");
//buttons
Button enterButton = new Button ("Enter");
enterButton.setOnAction(e -> enterButtonClicked());
enterButton.setMinWidth(200);
Button clearButton = new Button ("Clear");
clearButton.setOnAction(e -> clearButtonClicked());
clearButton.setMinWidth(50);
Button deleteButton = new Button ("Delete");
deleteButton.setOnAction(e -> deleteButtonClicked());
deleteButton.setMinWidth(50);
Button exitButton = new Button ("Exit");
exitButton.setOnAction(e -> exitButtonClicked());
exitButton.setMinWidth(50);
HBox hbox = new HBox();
hbox.setPadding(new Insets(25, 10, 50, 10));
hbox.setSpacing(10);
hbox.getChildren().addAll(nameInput, houseInput, streetInput, townInput, outletInput, zoneInput);
HBox buttons = new HBox();
buttons.setPadding(new Insets(10,10,10,10));
buttons.setSpacing(15);
buttons.setAlignment(Pos.CENTER);
buttons.getChildren().addAll(clearButton, enterButton, deleteButton, exitButton);
installationTable = new TableView<>();
installationTable.setItems(getInstallation());
installationTable.getColumns().addAll(installationID, nameColumn, houseNo, street, Town, numberOutlets, numberZones, installType, cost);
VBox vbox = new VBox();
vbox.getChildren().addAll(hbox,installationTable, buttons);
Scene scene = new Scene(vbox);
window.setScene(scene);
window.show();
}
I am using a "Main" class and a class called "Installation" with my variables and getters and setters.
This is my variables in the "Installation" Class
private String customerName;
private String streetName;
private String town;
private String installationType;
private double postCode;
private double houseNumber;
private int numZones;
private int numOutlets;
private double totalCost;
private double standardCost = 7200;
private double customCost;
private int installationNumber = 0;
Thank you to anybody that helps me, i have been trying at this for ages and cant quite seem to get it. Thanks so much! sorry if i am not posting correctly, still trying to learn.
I think I see your problem. This is the code that you have now:
if (numOutlets>=2 || numZones>=5)
installationType = "Custom";
else
installationType = "Standard";
This is what you need to change it to:
if (numZones>=2 || numOutlets>=5)
installationType = "Custom";
else
installationType = "Standard";
It appears based on the above code you had the variables switched.
Related
public void employeeMenu()
{
//ADD LOG OUT BUTTON SOMEWHERE
//setting stage
StackPane empMenuStage = new StackPane();
VBox empBox = new VBox(new Label("Employee Menu"));
empMenuStage.getChildren().add(empBox);
Scene empScene = new Scene(empMenuStage, 500, 500);
Stage empStage = new Stage();
empStage.setScene(empScene);
empStage.setTitle("Employee Menu");
TabPane tabPane = new TabPane();
Tab bookingReport = new Tab("Booking Report");
Tab checkOutGuest = new Tab("Check Out Guest");
Tab createGuestAccount = new Tab("Create Guest Account");
Tab editGuestInformation = new Tab("Edit Guest Info");
Tab createNewEmpAccount = new Tab("Create new Employee Account");
Tab editEmployeeAccount = new Tab("Edit Employee Account");
Tab editRoomStatus = new Tab("Edit Room Status");
tabPane.getTabs().add(bookingReport); //mitchell
tabPane.getTabs().add(checkOutGuest); //emma
tabPane.getTabs().add(createGuestAccount); //joey
tabPane.getTabs().add(editGuestInformation);
tabPane.getTabs().add(createNewEmpAccount);
tabPane.getTabs().add(editEmployeeAccount);
tabPane.getTabs().add(editRoomStatus);
VBox tabBox = new VBox(tabPane);
Scene scene = new Scene(tabBox, 500, 500);
empStage.setScene(scene);
empStage.setTitle("Employee Menu");
empStage.close();
empStage.show();
}
public Tab displayEmpMenu(Stage empStage)
{
//button for check out a value guest
//then enter name of value guest
//Enter room of value guest
//Confirmation Message (pick Y or N)
Tab test = new Tab("hi");
Button valueGuest = new Button("Check out Value Guest");
Button generalGuest = new Button("Check out General Guest");
valueGuest.setOnAction(e -> checkOutVG());
generalGuest.setOnAction(e -> checkOutGeneral());
GridPane layout = new GridPane();
layout.setPadding(new Insets(10, 10, 10, 10 ));
layout.setVgap(8);
GridPane.setConstraints(valueGuest, 0, 0);
GridPane.setConstraints(generalGuest,0, 1 );
layout.getChildren().addAll(valueGuest, generalGuest);
Scene scene = new Scene(layout, 650, 200 );
empStage.setScene(scene);
empStage.setTitle("Check Out Guest");
empStage.show();
//button for check out a general guest
//button for return to employee menu
return test;
}
public void checkOutVG()
{
TextField vgName = new TextField("Enter name of value guest");
String vgN = vgName.getText();
Label name = new Label("Value Guest Name");
TextField vgRoom = new TextField("Enter room of value guest");
Label roomNum = new Label("Value Guest Room");
double room = Double.parseDouble(vgRoom.getText());
int room1 = (int)room;
freeThisRoom(room1);
Label vgRoom1 = new Label("Value Guest Room");
TextField vgconfirm = new TextField("Confirmation: "
+ vgN + " is checking out of "
+ room1 + "(Y/N)");
vgconfirm.getText();
String text = "";
if (vgconfirm.getText().equalsIgnoreCase("Y"))
{
text = "Done. " + vgN + "is checked out of "
+ room1;
}
else
{
text = "You entered no. Please re-enter information.";
}
}
public void checkOutGeneral()
{
TextField name = new TextField("Enter name of general guest");
Label ggname = new Label("General Guest Name");
String name1 = name.getText();
TextField room = new TextField("Enter room number of general guest");
Label roomNum = new Label("General Guest Room");
double ggNum = Double.parseDouble(room.getText());
int ggRoom = (int)ggNum;
freeThisRoom(ggRoom);
TextField vgconfirm = new TextField("Confirmation: "
+ name + " is checking out of "
+ ggRoom + "(Y/N)");
vgconfirm.getText();
String text = "";
if (vgconfirm.getText().equalsIgnoreCase("Y"))
{
text = "Done. " + name + "is checked out of "
+ ggRoom;
}
else
{
text = "You entered no. Please re-enter information.";
}
}
I need help adding this content to the check out guest tab in the employee menu method. I'm new to javafx so if anyone could help me figure this out it would be greatly appreciated! I'm not sure what I am doing wrong or what I need to fix but I'm kind of lost. I've been scouring the web/textbooks for a solution but either I'm missing something big or I haven't come across the solution yet.
I am attempting to create about a dozen TextFields and was wondering if there is a quick and easy way to do this.
tfTime1 = new TextField();
tfActivity1 = new TextField();
tfTime2 = new TextField();
tfActivity2 = new TextField();
tfTime3 = new TextField();
tfActivity3 = new TextField();
tfTime4 = new TextField();
tfActivity4 = new TextField();
tfTime5 = new TextField();
tfActivity5 = new TextField();
tfTime6 = new TextField();
tfActivity6 = new TextField();
I feel like there's a more efficient way of doing this that I am not aware of
You could use a simple for loop to add new TextFields to a List:
List<TextField> timeTextFields = new ArrayList<>();
for (int i = 0; i < 5; i++) {
timeTextFields.add(new TextField("Time #" + i));
}
i have create a simple form with java jdk that contain a button, when user click the button it show the 2nd form and close the 1st form, but i have error like this in netbeans:
error: incompatible types: Scene cannot be converted to Parent
Scene secondScene = new Scene(scene2, 300,250);
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
now the full code of start :
public void start(Stage primaryStage) {
GridPane grid1 = new GridPane();
Button butt1 = new Button();
butt1.setText("Applique KPPV");
grid1.add(butt1, 2, 6);
Scene scene1 = new Scene(grid1, 300, 250);
primaryStage.setTitle("KNN With JDK");
primaryStage.setScene(scene1);
primaryStage.show();
butt1.setOnAction(e->{
GridPane grid = new GridPane();
// Labels & inputs Settings
Label number1 = new Label("Data 1 :");
Label number2 = new Label("Data 2 :");
Label number3 = new Label("Data 3 :");
Label number4 = new Label("Data 4 :");
Label number5 = new Label("Data 5 :");
Label numberk = new Label("K :");
Label resultat1 = new Label("The Result");
TextField txt1 = new TextField();
TextField txt2 = new TextField();
TextField txt3 = new TextField();
TextField txt4 = new TextField();
TextField txt5 = new TextField();
TextField txtk = new TextField();
grid.add(number1, 0, 0);
grid.add(number2, 0, 1);
grid.add(number3, 0, 2);
grid.add(number4, 0, 3);
grid.add(number5, 0, 4);
grid.add(numberk, 0, 5);
grid.add(resultat1, 0, 7);
grid.add(txt1, 1, 0);
grid.add(txt2, 1, 1);
grid.add(txt3, 1, 2);
grid.add(txt4, 1, 3);
grid.add(txt5, 1, 4);
grid.add(txtk, 1, 5);
Button butt = new Button();
butt.setText("Applique KPPV");
grid.add(butt, 0, 6);
// My Main Method
///////////////////////////////////
// ADDED THESE 5 LINES. NOW IT SHOWS A WINDOW WITH THESE VALUES FILLED IN
txt1.setText("0.0");
txt2.setText("0.0");
txt3.setText("0.0");
txt4.setText("0.0");
txt5.setText("0.0");
txtk.setText("10");
double insertedInt = Double.parseDouble(txt1.getText());
double insertedInt2 = Double.parseDouble(txt2.getText());
double insertedInt3 = Double.parseDouble(txt3.getText());
double insertedInt4 = Double.parseDouble(txt4.getText());
double insertedInt5 = Double.parseDouble(txt5.getText());
///////////////////////////////////
Scene scene = new Scene(grid, 300, 250);
// Final Action
butt.setOnAction(event -> {
double[] query = { insertedInt, insertedInt2, insertedInt3, insertedInt4, insertedInt5 };
int k = Integer.parseInt(txtk.getText());
List<City> cityList = new ArrayList<City>();
List<Result> resultList = new ArrayList<Result>();
cityList.add(new City(instances[0], "IRIS0"));
cityList.add(new City(instances[1], "IRIS1"));
cityList.add(new City(instances[2], "IRIS2"));
cityList.add(new City(instances[3], "IRIS3"));
cityList.add(new City(instances[4], "IRIS4"));
cityList.add(new City(instances[5], "IRIS5"));
cityList.add(new City(instances[6], "IRIS6"));
cityList.add(new City(instances[7], "IRIS7"));
cityList.add(new City(instances[8], "IRIS8"));
cityList.add(new City(instances[9], "IRIS9"));
// find distances
for (City city : cityList) {
double dist = 0.0;
for (int j = 0; j < city.cityAttributes.length; j++) {
dist += Math.pow(city.cityAttributes[j] - query[j], 2);
}
double distance = Math.sqrt(dist);
resultList.add(new Result(distance, city.cityName));
}
Collections.sort(resultList, new DistanceComparator());
String[] ss = new String[k];
for (int x = 0; x < k; x++) {
ss[x] = resultList.get(x).cityName;
}
String majClass = findMajorityClass(ss);
// System.out.println("The Nearest IRIS Class is : "+majClass);
resultat1.setText(majClass);
});
Scene secondScene = new Scene(scene, 500,500);
Stage secondStage = new Stage();
secondStage.setScene(secondScene); // set the scene
secondStage.setTitle("Second Form");
secondStage.show();
primaryStage.close(); // close the first stage (Window)
});
}
I have a problem.I created a program that will add two random numbers. I'm trying to put a Math.random() in a JTextField but it won't appear. Here's my code by the way:
public class RandomMathGame extends JFrame {
public RandomMathGame(){
super("Random Math Game");
int random2;
JButton lvl1 = new JButton("LEVEL 1");
JButton lvl2 = new JButton("LEVEL 2");
JButton lvl3 = new JButton("LEVEL 3");
JLabel line1 = new JLabel("Line 1: ");
final JTextField jtf1 = new JTextField(10);
JLabel line2 = new JLabel("Line 2: ");
final JTextField jtf2 = new JTextField(10);
JLabel result = new JLabel("Result: ");
final JTextField jtf3 = new JTextField(10);
JButton ans = new JButton("Answer");
JLabel score = new JLabel("Score: ");
JTextField jtf4 = new JTextField(3);
JLabel itm = new JLabel("Number of Items: ");
JTextField items = new JTextField(3);
FlowLayout flo = new FlowLayout();
setLayout(flo);
add(lvl1);
add(lvl2);
add(lvl3);
add(line1);
add(jtf1);
add(line2);
add(jtf2);
add(result);
add(jtf3);
add(ans);
add(score);
add(jtf4);
add(itm);
add(items);
setSize(140,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
lvl1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
int i, j = 10;
int i1 = Integer.valueOf(jtf1.getText());
int i2 = Integer.valueOf(jtf2.getText());
int i3 = i1 + i2;
final int random1 = (int)(Math.random() * 10 + 1);
for (i = 0; i <= j + 1; i++){
try{
jtf1.setText(String.valueOf(random1));
jtf2.setText(String.valueOf(random1));
jtf3.setText(String.valueOf(i3));
}catch(Exception ex){
ex.printStackTrace();
}
}
}
});
}
Never mind the lvl2 and lvl3 because it's the same in lvl1. And also, I want to loop them 10 times. I'm having difficulties on putting up those codes. Can someone help me? Thanks for your help. :)
Updating text fields in a loop won't produce the animated display that you likely want; only the last update will be seen. Instead, use a javax.swing.Timer to periodically update the fields. Related examples may be found here, here and here.
public class CustomCalculator extends Frame implements ActionListener{
Panel jp1 = new Panel();
Panel jp2 = new Panel();
Panel jp3 = new Panel();
Panel jp4 = new Panel();
Panel jp5 = new Panel();
Panel center_merge = new Panel();
Label l2 = new Label("Quantity : ");
TextField l2a = new TextField(20);
Label l3 = new Label("Invoice Value : ");
TextField l3a = new TextField(20);
Label l4 = new Label("Exchange Rate : ");
TextField l4a = new TextField(20);
Label l5 = new Label("Costing(A) : ");
TextField l5a = new TextField();
Label l6 = new Label("(A + 1%)(B) : ");
Label l6a = new Label();
Label l7 = new Label("BCD (C) : ");
Label l7a = new Label("");
Label l8 = new Label("CVD (D) : ");
Label l8a = new Label("");
Label l9 = new Label("Custom Education Cess (E) : ");
Label l9a = new Label("");
Label l10 = new Label("Custom Sec & Higher Edu.Cess (F) : ");
Label l10a = new Label("");
Label l11 = new Label("Additional Duty Imports (G) : ");
Label l11a = new Label("");
Label l12 = new Label("Total (H) : ");
Label l12a = new Label("");
Label l13 = new Label("Costing+Total (I) : ");
Label l13a = new Label("");
Label l14 = new Label("(H/Quantity) (J) : ");
Label l14a = new Label("");
Label l15 = new Label("4% SAD (G/Quantity) (K) : ");
Label l15a = new Label("");
Label l16 = new Label("Net Costing (L) : ");
Label l16a = new Label("");
Label l17 = new Label("Transportation (M) : ");
TextField l17a = new TextField(5);
Label l18 = new Label("Godown Rate (N) : ");
TextField l18a = new TextField(5);
Label l19 = new Label("Brokerage (O) : ");
TextField l19a = new TextField(5);
Label l20 = new Label("Actual Costing (P) : ");
Label l20a = new Label("");
Label l21 = new Label("Small Gatepass (Q) : ");
Label l21a = new Label("");
Label l22 = new Label("Big Gatepass (R) : ");
Label l22a = new Label("");
Button l2b = new Button("reset");
Button l3b = new Button("reset");
Button l4b = new Button("reset");
Button master_reset = new Button("reset all");
Button calc = new Button("Calculate");
public CustomCalculator()
{
super("Custom Calculator");
this.setSize(800,700);
jp1.setLayout(new FlowLayout());
//jp1.setBorder(BorderFactory.createLineBorder(Color.GRAY));
jp1.add(l2);
jp1.add(l2a);
jp1.add(l2b);
jp1.add(l3);
jp1.add(l3a);
jp1.add(l3b);
jp1.add(l4);
jp1.add(l4a);
jp1.add(l4b);
jp2.setLayout(new GridLayout(6,2));
//jp2.setBorder(BorderFactory.createLineBorder(Color.GRAY));
jp2.add(l5);
jp2.add(l5a);
jp2.add(l6);
jp2.add(l6a);
jp2.add(l7);
jp2.add(l7a);
jp2.add(l8);
jp2.add(l8a);
jp2.add(l9);
jp2.add(l9a);
jp2.add(l10);
jp2.add(l10a);
jp3.setLayout(new GridLayout(6,2));
//jp3.setBorder(BorderFactory.createLineBorder(Color.GRAY));
jp3.add(l11);
jp3.add(l11a);
jp3.add(l12);
jp3.add(l12a);
jp3.add(l13);
jp3.add(l13a);
jp3.add(l14);
jp3.add(l14a);
jp3.add(l15);
jp3.add(l15a);
jp3.add(l16);
jp3.add(l16a);
jp4.setLayout(new GridLayout(6,2));
//jp4.setBorder(BorderFactory.createLineBorder(Color.GRAY));
jp4.add(l17);
jp4.add(l17a);
jp4.add(l18);
jp4.add(l18a);
jp4.add(l19);
jp4.add(l19a);
jp4.add(l20);
jp4.add(l20a);
jp4.add(l21);
jp4.add(l21a);
jp4.add(l22);
jp4.add(l22a);
center_merge.setLayout(new GridLayout(1,3));
//center_merge.setBorder(BorderFactory.createLineBorder(Color.GRAY));
center_merge.add(jp2);
center_merge.add(jp3);
center_merge.add(jp4);
jp5.setLayout(new FlowLayout());
//jp5.setBorder(BorderFactory.createLineBorder(Color.GRAY));
jp5.add(calc);
jp5.add(master_reset);
this.setLayout(new BorderLayout());
this.add(jp1,BorderLayout.NORTH);
this.add(center_merge,BorderLayout.CENTER);
this.add(jp5,BorderLayout.SOUTH);
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
l2b.addActionListener(this);
l3b.addActionListener(this);
l4b.addActionListener(this);
calc.addActionListener(this);
master_reset.addActionListener(this);
this.setVisible(true);
}
public static void main(String[] args) {
new CustomCalculator();
}
#Override
public void actionPerformed(ActionEvent ae) {
double quantity = 0;
double invoice_value = 0;
double exchange_rate = 0;
double A=0;
double B=0;
double C=0;
double D=0;
double E=0;
double F=0;
double G=0;
double H=0;
double I=0;
double J=0;
double K=0;
double L=0;
double M = 0;
double N = 0;
double O=0;
double P=0;
double Q=0;
double R=0;
try
{
quantity = Double.parseDouble(l2a.getText());
invoice_value = Double.parseDouble(l3a.getText());
exchange_rate = Double.parseDouble(l4a.getText());
M = Double.parseDouble(l17a.getText());
N = Double.parseDouble(l18a.getText());
O = Double.parseDouble(l19a.getText());
A = invoice_value*exchange_rate;
B = A+(0.01*A);
C = 0.075*B;
D = 0.12*(B+C);
E = 0.02*(C+D);
F = 0.01*(C+D);
G = 0.04*(B+C+D+E+F);
H = C+D+E+F+G;
I = A+H;
J = H/quantity;
K = G/quantity;
L = J-K;
P = L+M+N+O;
Q = (0.12*B)/quantity;
R = Q+K;
if(ae.getActionCommand().equals("calc"))
{
l5a.setText(String.valueOf(A));
l6a.setText(String.valueOf(B));
l7a.setText(String.valueOf(C));
l8a.setText(String.valueOf(D));
l9a.setText(String.valueOf(E));
l10a.setText(String.valueOf(F));
l11a.setText(String.valueOf(G));
l12a.setText(String.valueOf(H));
l13a.setText(String.valueOf(I));
l14a.setText(String.valueOf(J));
l15a.setText(String.valueOf(K));
l16a.setText(String.valueOf(L));
l20a.setText(String.valueOf(P));
l21a.setText(String.valueOf(Q));
l22a.setText(String.valueOf(R));
}
else if(ae.getActionCommand().equals("master_reset"))
{
l5a.setText("");
l2a.setText("");
l3a.setText("");
l4a.setText("");
}
}
catch (Exception ex)
{
l5a.setText(ex.toString());
// l3a.setText(ex.toString());
}
}
}
After I click the Calculate button (button calc) the calculated values do not appear in the respective labels and an exception is shown saying java.lang.NumberFormatException: Empty string. I am not able to figure out the solution. please help.
the line exchange_rate = Double.parseDouble(l4a.getText()); gives you this exception, because there is no value in l4a and you are trying to parse it into a double value,
try printing the exception in the catch clause.
It's probably a relatively safe bet to say that it is happening here at the beginning of your function, though you should provide the actual exception and line number for us.
quantity = Double.parseDouble(l2a.getText());
invoice_value = Double.parseDouble(l3a.getText());
exchange_rate = Double.parseDouble(l4a.getText());
M = Double.parseDouble(l17a.getText());
N = Double.parseDouble(l18a.getText());
O = Double.parseDouble(l19a.getText());
Make sure that each of these fields actually has numeric text in it. I would recommend putting a logging line or an alert line to state their values before this is executed. Better yet, you can catch the first line in a debugger and look at the the values of all of the items you're calling getText() on. I bet one has an empty string.