Java Create a cash register application (window builder). The program will display a menu in the fast-food as follows:

Cheeseburger 55.00
Pepsi 25.00
Chips 35.00
Coke 20.00
Fries 45.00
Sundae 40.00
The user will choose an item to purchase. After the user selects an item to purchase, the user will input the quantity of the item and compute the amount due. A tax is deducted from the total amount purchased, which can be senior 10% or PWD 15%, and a service charge of 2% is added. Output should include the product bought, the total amount purchased, discounts, deductions, the amount given, and any changes if any.

Sure, here's a Java program that creates a cash register application using WindowBuilder:

```java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class CashRegisterApplication extends JFrame {
private JLabel lblProduct, lblQuantity, lblDiscount, lblAmountDue, lblTotalAmount, lblDeductions, lblAmountGiven, lange;
private JTextField txtQuantity, txtAmountGiven;
private JButton btnCompute;
private JComboBox<String> cmbProduct, cmbDiscount;

private String[] products = {"Cheeseburger", "Pepsi", "Chips", "Coke", "Fries", "Sundae"};
private double[] prices = {55.00, 25.00, 35.00, 20.00, 45.00, 40.00};

public CashRegisterApplication() {
setTitle("Cash Register Application");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

lblProduct = new JLabel("Product:");
cmbProduct = new JComboBox<>(products);

lblQuantity = new JLabel("Quantity:");
txtQuantity = new JTextField(10);

lblDiscount = new JLabel("Discount:");
cmbDiscount = new JComboBox<>(new String[] {"Senior (10%)", "PWD (15%)"});

lblAmountDue = new JLabel("Amount Due:");
lblTotalAmount = new JLabel("-");

lblDeductions = new JLabel("Deductions:");
lblDeductions.setVisible(false);

lblAmountGiven = new JLabel("Amount Given:");
txtAmountGiven = new JTextField(10);
txtAmountGiven.setEnabled(false);

lange = new JLabel("Change:");
lange.setVisible(false);

btnCompute = new JButton("Compute");
btnCompute.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
computeAmount();
}
});

setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.insets = new Insets(5, 5, 5, 5);

add(lblProduct, gbc);
gbc.gridx++;
add(cmbProduct, gbc);

gbc.gridx = 0;
gbc.gridy++;
add(lblQuantity, gbc);
gbc.gridx++;
add(txtQuantity, gbc);

gbc.gridx = 0;
gbc.gridy++;
add(lblDiscount, gbc);
gbc.gridx++;
add(cmbDiscount, gbc);

gbc.gridx = 0;
gbc.gridy++;
add(lblAmountDue, gbc);
gbc.gridx++;
add(lblTotalAmount, gbc);

gbc.gridx = 0;
gbc.gridy++;
add(lblDeductions, gbc);

gbc.gridx = 0;
gbc.gridy++;
add(lblAmountGiven, gbc);
gbc.gridx++;
add(txtAmountGiven, gbc);

gbc.gridx = 0;
gbc.gridy++;
add(lange, gbc);

gbc.gridx = 1;
gbc.gridy++;
add(btnCompute, gbc);

pack();
setLocationRelativeTo(null);
setResizable(false);
}

private void computeAmount() {
String selectedProduct = cmbProduct.getSelectedItem().toString();
int quantity = Integer.parseInt(txtQuantity.getText());
double price = getPrice(selectedProduct);
double amountDue = quantity * price;

double discountRate;
if (cmbDiscount.getSelectedItem().toString().equals("Senior (10%)")) {
discountRate = 0.10;
} else {
discountRate = 0.15;
}
double deductions = amountDue * discountRate;
double serviceCharge = amountDue * 0.02;
double totalAmount = amountDue + serviceCharge;

String amountDueStr = String.format("%.2f", amountDue);
String totalAmountStr = String.format("%.2f", totalAmount);
String deductionsStr = String.format("%.2f", deductions);

lblTotalAmount.setText(amountDueStr);
lblTotalAmount.setVisible(true);

lblDeductions.setText("Deductions: - " + deductionsStr);
lblDeductions.setVisible(true);

txtAmountGiven.setEnabled(true);

txtAmountGiven.requestFocus();
txtAmountGiven.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
double amountGiven = Double.parseDouble(txtAmountGiven.getText());
double change = amountGiven - totalAmount;
String changeStr = String.format("%.2f", change);
lange.setText("Change: " + changeStr);
lange.setVisible(true);
}
});
}

private double getPrice(String product) {
for (int i = 0; i < products.length; i++) {
if (products[i].equals(product)) {
return prices[i];
}
}
return 0.00;
}

public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new CashRegisterApplication().setVisible(true);
}
});
}
}
```

To run this program, make sure you have the WindowBuilder plugin installed in your Eclipse IDE. You can copy and paste the above code into a new Java project, then run it to launch the Cash Register Application window. You can select a product, enter the quantity, choose a discount, and click the "Compute" button to calculate the amount due. The deductions (discount), total amount, and change will be displayed accordingly.

Please note that this program assumes valid input from the user (e.g., numerical quantity, valid discount selection, etc.). Error handling and validation can be added as per your requirements.

To create a cash register application using WindowBuilder in Java, you'll need to have Eclipse IDE installed.

1. Set up the project:
- Open Eclipse and create a new Java project.
- Right-click on the project folder, select "New," then choose "Class." Name the class "CashRegisterApp" and click "Finish."
- Now, we need to add the WindowBuilder Swing library to our project. Right-click on the project folder, select "Properties," then go to "Java Build Path."
- Click on "Libraries," then click "Add Library."
- Select "WindowBuilder Swing Library" and click "Next."
- Accept the default library name and click "Finish," followed by "Apply and Close."

2. Design the user interface:
- Open the "CashRegisterApp.java" class file.
- Switch to Design view by clicking on the "Design" tab at the bottom of the code editor.
- Design the user interface by dragging and dropping components from the palette onto the frame.
- For this application, you'll need a JFrame, JLabels, JTextFields, JButtons, and a JTextArea to display the output.

3. Write the code:
- Switch back to the "Source" tab to write the code for the application.
- Define the necessary variables and components by adding the following private fields inside the class:
```java
private JFrame frmCashRegister;
private JTextField txtItemName;
private JTextField txtQuantity;
private JButton btnCalculate;
private JTextArea txtOutput;
```
- Inside the class constructor, initialize the frame and components:
```java
public CashRegisterApp() {
initialize();
}

private void initialize() {
frmCashRegister = new JFrame();
frmCashRegister.setTitle("Cash Register Application");
frmCashRegister.setBounds(100, 100, 450, 300);
frmCashRegister.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmCashRegister.getContentPane().setLayout(null);

// Add JLabels, JTextFields, and JButtons to the frame

// Add the event listener to the Calculate button
btnCalculate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
calculateAmountDue();
}
});
}
```
- Implement the `calculateAmountDue()` method to compute the amount due based on the user's input:
```java
private void calculateAmountDue() {
// Get the item name and quantity from the text fields
String itemName = txtItemName.getText();
int quantity = Integer.parseInt(txtQuantity.getText());

// Define the prices and discounts for each item
double cheeseburgerPrice = 55.00;
double pepsiPrice = 25.00;
double chipsPrice = 35.00;
double cokePrice = 20.00;
double friesPrice = 45.00;
double sundaePrice = 40.00;

// Compute the total amount purchased
double totalAmountPurchased = 0;
switch (itemName) {
case "Cheeseburger":
totalAmountPurchased = cheeseburgerPrice * quantity;
break;
case "Pepsi":
totalAmountPurchased = pepsiPrice * quantity;
break;
case "Chips":
totalAmountPurchased = chipsPrice * quantity;
break;
case "Coke":
totalAmountPurchased = cokePrice * quantity;
break;
case "Fries":
totalAmountPurchased = friesPrice * quantity;
break;
case "Sundae":
totalAmountPurchased = sundaePrice * quantity;
break;
}

// Compute the discount and deductions based on PWD or senior status
double discount = 0;
if (itemName.equals("Cheeseburger") && (discountType.equals("PWD") || discountType.equals("Senior"))) {
if (discountType.equals("PWD")) {
discount = totalAmountPurchased * 0.15;
} else if (discountType.equals("Senior")) {
discount = totalAmountPurchased * 0.1;
}
}

// Compute the amount due
double serviceCharge = totalAmountPurchased * 0.02;
double amountDue = totalAmountPurchased + serviceCharge - discount;

// Display the output in the text area
txtOutput.setText("Product Bought: " + itemName + "\n"
+ "Total Amount Purchased: " + totalAmountPurchased + "\n"
+ "Discount: " + discount + "\n"
+ "Amount Due: " + amountDue);
}
```
- Run the application:
```java
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
CashRegisterApp window = new CashRegisterApp();
window.frmCashRegister.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
```
4. Customize the UI:
- Adjust the layout, add labels, text fields, and buttons as desired.
- Set the appropriate names for the component variables.

That's it! You've created a basic cash register application using WindowBuilder in Java. Don't forget to save your files and run the application to test it out.

To create a cash register application in Java with Window Builder, you can follow these steps:

Step 1: Set up the GUI
- Start by creating a new Java project in your preferred IDE (e.g., Eclipse, IntelliJ).
- Create a new JFrame form using Window Builder in your IDE.
- Design the GUI to include labels, text fields, buttons, and any other components needed to display the menu and capture user input.

Step 2: Define the menu items and their prices
- In your Java class, define the menu items and their prices using variables. For example:
```java
double cheeseburgerPrice = 55.00;
double pepsiPrice = 25.00;
double chipsPrice = 35.00;
// and so on...
```

Step 3: Handle user input and perform calculations
- Add action listeners to the buttons or any other components that will trigger events.
- When a menu item button is clicked, prompt the user for the quantity of the item using a input dialog or a text field.
- Calculate the total amount due by multiplying the quantity with the item's price.
- Apply the appropriate tax deduction based on user input (senior 10% or PWD 15%) and calculate the discounted amount.
- Add a service charge of 2% to the total amount purchased.
- Compute the change by subtracting the amount given by the customer from the total amount due.

Step 4: Display the output
- Create labels or text fields to display the product bought, total amount purchased, discounts, deductions, amount given, and any change.
- Update the labels or text fields with the calculated values.

Here's a simplified example to demonstrate the above steps:

```java
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class CashRegisterApp extends JFrame {
private JButton cheeseburgerButton;
private JButton pepsiButton;
// Other buttons and components

private double cheeseburgerPrice = 55.00;
private double pepsiPrice = 25.00;
// Other menu item prices

public CashRegisterApp() {
initComponents();

cheeseburgerButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String quantityString = JOptionPane.showInputDialog("Enter quantity of Cheeseburger:");
int quantity = Integer.parseInt(quantityString);

double totalAmountDue = cheeseburgerPrice * quantity;
// Apply tax deductions and service charge
// Calculate change

// Update the labels or text fields to display the results
}
});

// Add action listeners for other menu item buttons

// Configure and display the JFrame
}

// Other methods and components initialization skipped for brevity

public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new CashRegisterApp().setVisible(true);
}
});
}
}
```

Please note that this is a simplified example to give you a starting point. You would need to handle error cases, format numbers, and implement the complete functionality based on your specific requirements.