import javax.swing.JFrame;
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Scanner;
import javax.swing.JOptionPane;
import java.awt.event.*;
import javax.swing.JCheckBox;
import java.util.Random;
public class off extends JFrame implements ActionListener {
JButton mybotton;
JRadioButton c1,c2,c3,c4,c5,c6;
off()
{
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame myframe = new JFrame("50% OFF Food");
myframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel1 = new JPanel();
panel1.setBorder(BorderFactory.createTitledBorder("Food"));
c1 = new JRadioButton("Hambuger 100");
c2 = new JRadioButton("Fries 50");
c3 = new JRadioButton("Cheesestick 20");
c4 = new JRadioButton("Coke 50");
c5 = new JRadioButton("Sprite 50");
c6 = new JRadioButton("Royal 20");
mybotton = new JButton("Total");
mybotton.setBounds(50, 50, 80 ,30);
mybotton.addActionListener(this);
panel1.add(c1);
panel1.add(c2);
panel1.add(c3);
panel1.add(mybotton);
panel1.add(c4);
panel1.add(c5);
panel1.add(c6);
myframe.add(panel1);
myframe.setSize(1375, 350);
myframe.setVisible(true);
}
@Override
public void actionPerformed (ActionEvent e)
{
float amount = 0;
String m1 = " ";
if(c1.isSelected())
{
amount += 100/2;
m1 += "Hamburger 50\n";
}
if(c2.isSelected())
{
amount += 50/2;
m1 += "Fries 25\n";
}
if(c3.isSelected())
{
amount += 20/2;
m1 += "CheeseStick 10\n";
}
if(c4.isSelected())
{
amount += 50/2;
m1 += "Coke 25\n";
}
if(c5.isSelected())
{
amount += 50/2;
m1 += "Sprite 25\n";
}
if(c6.isSelected())
{
amount += 50/2;
m1 += "Royal 25\n";
}
m1 +="----------------------------------------\n";
JOptionPane.showMessageDialog(this, m1 + "Total: " + amount);
}
public static void main (String[]args)
{
new off();
}
}