Create an online order form and calculator for Joe’s Coffee House. Joe sells regular and decaff coffee. Customers have the option of adding cream, sugar, artificial sweetener, cinnamon and caramel to their coffee. They can have any number of the options available or none at all. Customers can add one or more muffins to their order. Possible muffins are blueberry, chocolate chip, banana nut and bran.
Coffee is $3.00
Coffee Add-Ins are $0.25 a piece
Muffins are $2.25 apiece.
Your GUI should allow the customer to make their coffee and muffin choices and then calculate the cost. Be sure to include 7% sales tax when calculating the order.
You must use JavaFX components- Swing or AWT GUI’s will be penalized points. DO NOT USE GUI BUILDER TOOLS in Eclipse or other IDE- this should be your code not a tool’s. I will deduct points for this.
CoffeeHouse.java
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class CoffeeHouse extends JFrame implements
ActionListener{
JCheckBox box1;
JComboBox<String> combo1;
String flavours[] =
{"None","Cream","Sugar","artificial","sweetener","cinnamon","caramel"};
JLabel
label1,label2,label3,label4,label5,label6,label7;
JTextField field1,field2,field3,field4;
JButton order;
public CoffeeHouse(){
this.setTitle("Coffee
House");
this.setSize(400, 400);
this.setLayout(new
GridLayout(7,2));
JPanel panel1 = new JPanel(new
FlowLayout());
JPanel panel2 = new JPanel(new
FlowLayout());
JPanel panel3 = new JPanel(new
FlowLayout());
JPanel panel4 = new JPanel(new
FlowLayout());
JPanel panel5 = new JPanel(new
FlowLayout());
JPanel panel6 = new JPanel(new
FlowLayout());
JPanel panel7 = new JPanel(new
FlowLayout());
label1 = new JLabel("Select
Coffee:");
panel1.add(label1);
box1 = new JCheckBox();
panel1.add(box1);
label2 = new JLabel("Add
Flavour:");
panel1.add(label2);
combo1 = new
JComboBox<String>(flavours);
panel1.add(combo1);
add(panel1);
label7 = new JLabel("Enter no.of
Muffins Here: ");
panel7.add(label7);
label3 = new
JLabel("Blueberry:");
panel2.add(label3);
field1 = new
JTextField("0",10);
panel2.add(field1);
add(panel2);
label4 = new JLabel("Chocolate
Chip:");
panel3.add(label4);
field2 = new
JTextField("0",10);
panel3.add(field2);
add(panel3);
label5 = new JLabel("Banana
nut:");
panel4.add(label5);
field3 = new
JTextField("0",10);
panel4.add(field3);
add(panel4);
label6 = new JLabel("Bran:");
panel5.add(label6);
field4 = new
JTextField("0",10);
panel5.add(field4);
add(panel5);
order = new JButton("Order
Now!");
order.addActionListener(this);
panel6.add(order);
add(panel6);
setVisible(true);
}
public static void main(String args[]){
new CoffeeHouse();
}
@Override
public void actionPerformed(ActionEvent arg0) {
double cost=0.0;
if(box1.isSelected()){
cost +=
3.0;
if(combo1.getSelectedIndex() != 0)
cost += 0.25;
}
cost +=
Double.parseDouble(field1.getText())*2.25;
cost +=
Double.parseDouble(field2.getText())*2.25;
cost +=
Double.parseDouble(field3.getText())*2.25;
cost +=
Double.parseDouble(field4.getText())*2.25;
cost += (cost*0.07);
System.out.println(cost);
}
}
Create an online order form and calculator for Joe’s Coffee House. Joe sells regular and decaff...